PHP Table Hyperlink - php

I have a table that returns information from mysql. However, I want to hyperlink each postcode so that when the user clicks on one it will redirect them to an appropriate page. Here is the code that is in the table:
<table style="border:2px solid black; border-collapse:collapse;" cellspacing="2" cellpadding="2" align="center">
<tr align="center" width="auto">
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Consultation Date </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Patient Health Care Number </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Location </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Post Code </b></td>
<td bgcolor="#66CCFF" style="border:2px solid black;"><b> Update Record </b></td>
</tr>
<?php
$i=0;
while ($i < $num) {
$f1=mysql_result($result,$i,"Consultation Date");
$f2=mysql_result($result,$i,"Patient HCN");
$f3=mysql_result($result,$i,"Location");
$f4=mysql_result($result,$i,"Post Code");
?>
<tr>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo $f1; ?></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><b><?php echo $f2; ?></b></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo $f3; ?></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo "<a href=\"coveragehcp.php?patient= ". $f2 ."\">"?><b><?php echo $f4; ?></b></td>
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo "<button onclick=\"window.location.href='hcp_form_update.php?patient=$f2'\">"?>Update Record</button></td> <!-- This button redirects the user to the auto-populated form that holds the patients information which allows the user to update it -->
</tr>
<?php
$i++;
}
?>
However when the user click on the link below I want it to redirect them to another page according to the post code clicked.
<td align="center" bgcolor="#FFFFFF" style="border:2px solid black;"><?php echo "<a href=\"coveragehcp.php?patient= ". $f2 ."\">"?><b><?php echo $f4; ?></b></td>

What I would do is to use the post code as a parameter in the GET, and then use the $_GET['postcode'] to achieve which page should be presented for the user.
so your PHP code for the link would look something like:
<a href=\"coveragehcp.php?patient= ".$f2."&postcode=".$f4."\">"?><b><?php echo $f4; ?></b></td>
and on the coveragehcp.php page use this
$postcode = $_GET['postcode'];
if(!empty($postcode))
{
if($postcode == 90210) {
//Echo beverly hills page
}
else {
//Echo default page
}
}

Related

While the data I have taken with xml on localhost is working, the page does not work completely when I throw it to the hosting

While the data I have taken with XML on localhost is working, the page does not work completely when I throw it to the hosting. Not only the XML code, but also other php and html codes are disabled. Has anyone encountered such a problem before? if so can you help?
php codes
`
$link="https://www.tcmb.gov.tr/kurlar/today.xml";
$icerik=simplexml_load_file($link);
/*echo "<pre>";
print_r($icerik);
echo "</pre>";*/
$usd_kodu=$icerik->Currency[0]["CurrencyCode"];
$Usd_adi=$icerik->Currency[0]->Isim;
$Usd_birim=$icerik->Currency[0]->Unit;
$Usd_alis=$icerik->Currency[0]->ForexBuying;
$Usd_satis=$icerik->Currency[0]->ForexSelling;
$Usd_efektifAlis=$icerik->Currency[0]->BanknoteBuying;
$Usd_efektifSatis=$icerik->Currency[0]->BanknoteSelling;
$usd_id=1; // veri tabanı idleri xml ile çekilmedi
`
html codes
`
<tr>
<th width="133" height="36" align="center" style="font-style: normal; font-weight: bold; font-size: large;" scope="col">Döviz Kuru</th>
<th width="113" align="center" style="font-style: normal" scope="col">Adı</th>
<th width="113" align="center" style="font-style: normal" scope="col">Kodu</th>
<th width="113" align="center" style="font-style: normal" scope="col">Birimi</th>
<th width="118" align="center" style="font-style: normal" scope="col">Alış Fiyatı</th>
<th width="130" align="center" style="font-style: normal" scope="col">Satış Fiyatı</th>
<th width="99" align="center" style="font-style: normal" scope="col">Efektif Alış</th>
<th width="119" align="center" style="font-style: normal" scope="col">Efektif Fiyatı</th>
</tr>
</thead>
<tbody>
<tr>
<th rowspan="3" align="center" valign="middle" style="font-size: medium" scope="row">TCMB</th>
<td height="51" align="center"><?php echo $Usd_adi; ?></td>
<td height="51" align="center"><?php echo $usd_kodu; ?></td>
<td align="center"><?php echo $Usd_birim; ?></td>
<td align="center"><?php echo $Usd_alis; ?></td>
<td align="center"><?php echo $Usd_satis; ?></td>
<td align="center"><?php echo $Usd_efektifAlis; ?></td>
<td align="center"><?php echo $Usd_efektifSatis; ?></td>
</tr>
`
I was hoping the codes would work on hosting as well as on localhost but it didn't
Is SimpleXML support enabled on your hosting? You can check it with
phpinfo();
Also make sure you have a valid ssl certification

php foreach loop repeat td's 2 times in a tr

I creating a PDF for print the address of users. I have the below HTML structure:
I have tried with the below code:
<?php $i=0; ?>
<tr valign="top">
foreach ($users as $user): ?>
<?php if ($i % 2 == 1) {?>
<tr valign="top">
<?php } ?>
But it's now work as expect.
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
<tr valign="top">
<td width="48%" align="left" valign="top" style="padding:10px 10px 15px; font-size:14px; color:#333; font-family:Verdana, Geneva, sans-serif; border:1px solid #ccc;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="25" valign="bottom">Name</td>
<td width="78%" valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom"> </td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom">Phone</td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
</table></td>
<td width="4%" align="left"> </td>
<td width="48%" align="left" style="padding:10px 10px 15px; font-size:14px; color:#333; font-family:Verdana, Geneva, sans-serif; border:1px solid #ccc;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="25" valign="bottom">Name</td>
<td width="78%" valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom"> </td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom">Phone</td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
</table></td>
</tr>
<tr valign="top">
<td height="15" align="left"></td>
<td height="15" align="left"></td>
<td height="15" align="left"></td>
</tr>
</table>
In the abolve table I want to repeat the TD in each TR 2 times and added the blank TR after every TR.
The above HTML out should be the below image:
Could any one can help me out this.
If I get properly what you're looking for : I want to repeat in one TR repeat two TD
Then this code:
<?php
error_reporting(E_ALL); ini_set('display_errors', 1);
echo"<table>";
for ($i = 1; $i <= 10; $i++) {
if(($i % 2) == 1) // odd -> start TR
{ echo "<tr><td class=\"dark\">$i</td>"; }
else // even -> close TR
{ echo "<td class=\"red\">$i</td></tr><tr><td colspan=\"2\">whatever here</tr>"; }
}
echo"</table>";
?>
will give you this output :
<table>
<tr><td class="dark">1</td><td class="red">2</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">3</td><td class="red">4</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">5</td><td class="red">6</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">7</td><td class="red">8</td></tr><tr><td colspan="2">whatever here</tr>
<tr><td class="dark">9</td><td class="red">10</td></tr><tr><td colspan="2">whatever here</tr>
</table>
EDIT after you comment : added one 'blank' TR
Try below solution you missed out to close
<?php
$i=0;
foreach ($users as $user){
if ($i % 2 == 0) {?>
<tr valign="top">
<?php } ?>
<td width="48%" align="left" style="padding:10px 10px 15px; font-size:14px; color:#333; font-family:Verdana, Geneva, sans-serif; border:1px solid #ccc;"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="22%" height="25" valign="bottom">Name</td>
<td width="78%" valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom"> </td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
<tr>
<td height="40" valign="bottom">Phone</td>
<td valign="bottom" style="border-bottom:1px dashed #ccc;"> </td>
</tr>
</table></td>
<?php if ($i % 2 == 0) {?>
</tr>
<?php } }?>

Print Report only 6 data for 1 page

i create a report. i try print preview this report.
but i want show 6 data/page page size a4 (landscape).
i already try loop 24 data. and try print preview in google chrome
there 1 data must be down to page 2
see my picture
[![enter image description here][1]][1]
then i check page 2 already same.
this page 2
[![enter image description here][2]][2]
How to fix this, i want report show only 6 data/page
this is my full code, you can try in localhost.
<style>
#caption
{
color:white;
font-weight:bold;
text-align:center;
background-color: #4CAF50;
}
table
{
border-collapse: collapse;
}
th, td
{
padding: 0px;
font-family:arial;
font-size:13px
}
tr:nth-child(even){background-color: #f2f2f2}
th {
background-color: #4CAF50;
color: white;
}
</style>
<table align="center" width="100%" border="1">
<tr>
<td colspan="7" style="vertical-align: top;" id="caption"><font size="3">Data Pendaftar</font></td>
</tr>
<?php
$x = 1;
while($x <= 24)
{
?>
<tr>
<td id="caption">Foto Siswa/i</td>
<td id="caption">Nama Lengkap Siswa/i</td>
<td id="caption">Tempat Lahir</td>
<td id="caption">Tanggal Lahir</td>
<td id="caption">Usia</td>
<td id="caption">L/P</td>
<td id="caption">Agama</td>
</tr>
<tr>
<td align="center" rowspan="3">
<img border="1" src="https://akphoto4.ask.fm/769/854/890/910003014-1s093lj-dc47ceo09kenpt5/original/avatar.jpg"style="width:80px;height:80px;">
</td>
<td align="center">Vasco Da Gama</td>
<td align="center">Spain</td>
<td align="center">01 February 1800</td>
<td align="center">79</td>
<td align="center">L</td>
<td align="center">Kristen</td>
</tr>
<tr>
<td id="caption" colspan="2">Alamat</td>
<td id="caption" colspan="2">No. Telpon | No. Hp </td>
<td id="caption" >Tanggal Daftar</td>
<td id="caption">Status</td>
</tr>
<tr>
<td colspan="2">Spain</td>
<td colspan="2" align="center">0800000000</td>
<td >07 Februari 2000 13:15:33</td>
<td align="center">Pending</td>
</tr>
<?php
$x++;
}
?>
</table>
In this situation, you could create a separate table per page with only 6 rows. Only display the "Data Pendaftar" on the first page, add class="break" to every table except the table on the last page and add a CSS rule table.break{page-break-after:always}. I added a <br /> after each table, so it looks good in the browser before it prints. This will always print 6 rows per page, even when you're accidentally in portrait mode...
<style>
#caption{color:white;font-weight:bold;text-align:center;background-color:#4CAF50}
table{border-collapse:collapse}
th, td{padding: 0px;font-family:arial;font-size:13px}
tr:nth-child(even){background-color:#f2f2f2}
th{background-color:#4CAF50;color:white}
table.break{page-break-after:always}
</style>
<?php $i = 1; while ($i <= 4) { ?>
<table align="center" width="100%" border="1"<?php if ($i < 4) { ?> class="break" <? } ?>>
<?php if ($i == 1) { ?>
<tr>
<td colspan="7" style="vertical-align: top;" id="caption"><font size="3">Data Pendaftar</font></td>
</tr>
<?php } $x = 1; while ($x <= 6) { ?>
<tr>
<td id="caption">Foto Siswa/i</td>
<td id="caption">Nama Lengkap Siswa/i</td>
<td id="caption">Tempat Lahir</td>
<td id="caption">Tanggal Lahir</td>
<td id="caption">Usia</td>
<td id="caption">L/P</td>
<td id="caption">Agama</td>
</tr>
<tr>
<td align="center" rowspan="3">
<img border="1" src="https://akphoto4.ask.fm/769/854/890/910003014-1s093lj-dc47ceo09kenpt5/original/avatar.jpg"style="width:80px;height:80px;">
</td>
<td align="center">Vasco Da Gama</td>
<td align="center">Span</td>
<td align="center">01 Feb 1800</td>
<td align="center">79</td>
<td align="center">L</td>
<td align="center">Kristen</td>
</tr>
<tr>
<td id="caption" colspan="2">Alamat</td>
<td id="caption" colspan="2">No. Telpon | No. Hp </td>
<td id="caption" >Tanggal Daftar</td>
<td id="caption">Status</td>
</tr>
<tr>
<td colspan="2">Spain</td>
<td colspan="2" align="center">021000000 | 0800000000</td>
<td >07 Februari 2000 13:15:33</td>
<td align="center">Pending</td>
</tr>
<?php $x++; } ?>
</table>
<br />
<?php $i++; } ?>

How to add contents in new page using TCPDF?

I am using TCPDF stuff, I have created a PDF page with some Information. But i need to show some data to next page deliberately.
pdf -> AddPage();
above code is used to create a new page which i know. But i wanna add specific data to this particular page would be the problem.
Help me to come out on this issue.
I have written my code like this
while($row = mysql_fetch_array($query)){
$inv = $row["INVNUM"];
$weight = $row["WEIGHT"];
if($i<4){
if($row["SIZECODE"] == "02"){
$temp .= '<tr nobr="true">
<td class="size1" style="border:1px solid #000">'.$json_a[$i]["S"].'</td>
<td class="size2" style="border:1px solid #000">'.$json_a[$i]["M"].'</td>
<td class="size3" style="border:1px solid #000">'.$json_a[$i]["L"].'</td>
<td class="size4" style="border:1px solid #000">'.$json_a[$i]["XL"].'</td>
<td class="size5" style="border:1px solid #000">'.$json_a[$i]["2X"].'</td>
<td class="size6" style="border:1px solid #000">'.$json_a[$i]["3X"].'</td>
</tr>';
}
else if($row["SIZECODE"] == "03"){
$temp .= '<tr>
<td style="border:1px solid #000">'.$json_a[$i]["32"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["34"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["36"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["38"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["40"].'</td>
<td style="border:1px solid #000">'.$json_a[$i]["42"].'</td>
</tr>';
}
$i = $i+1;
}
else{
$pdf ->AddPage();
$i = 0;
$temp.='<tr nobr="true">
<td colspan="18" style="border:1px solid #000">All sales are Final.</td>
<td colspan="2" style="border:1px solid #000">SUB TOTAL:</td>
<td style="border:1px solid #000"></td>
<td style="border:1px solid #000"></td>
</tr>
<tr>
<td colspan="18" rowspan="2" style="border:1px solid #000">Number # : '.$rowFix["Num"].' </td>
</tr>
<tr>
<td colspan="2">TOTAL DUE: $</td>
<td style="border:1px solid #000"></td>
<td style="border:1px solid #000"></td>
</tr>';
}
}
I have to bring the table rows to the next page when the $i value greater than 4.
$pdf->AddPage('P', 'A4');
$pdf->Cell(0, 0, 'A4 PORTRAIT', 1, 1, 'C');
First, output the content for the first page. Then:
pdf -> AddPage();
Then, output for the second page. Anything sent after this command will be outputted onto the second page.

How to post many data from a view to controller?

I am using codeigniter.I have a table in my view. When one row is filled totally that data must be posted to my controller class. How to do this.
My view page.
<table style=" border-collapse: collapse;">
<tr>
<th>Employee</th>
<th>Start Time</th>
<th>ID</th>
<th>Mins</th>
<th>Type</th>
</tr>
<tr id="1">
<td contenteditable="true"><?php echo form_dropdown('employee', $options_category, set_value('employee'),'style="border-radius:0px; height:15px; font-size:10px; width:70px"');?></td>
<td contenteditable="true"><?php echo $date->format( 'H:i' ); ?></td>
<td contenteditable="true" ondblclick="mylist()"><?=$products['id']?></td>
<td contenteditable="true" class="nr"><?=$products['mins']?></td>
<td contenteditable="true"><?=$products['type']?></td>
</tr>
<tr id="2">
<td contenteditable="true"><?php echo form_dropdown('employee', $options_category, set_value('employee'),'style="border-radius:0px; height:15px; font-size:10px; width:70px"');?></td>
<td contenteditable="true"></td>
<td contenteditable="true" ondblclick="mylist()"><?=$products['id']?></td>
<td contenteditable="true"></td>
<td contenteditable="true"></td>
</tr>
</table>
I need to post the id that is filled totally.How to do this can someone help me code?

Categories