Replace buttons with image in PHP code - php

I am trying to display images in place of buttons for various activities like Edit Record, Delete Record, Download, Save, Reset. I am able to show the image but the result is very output is looks very childish and nonprofessional. Actually images are coming on button as shown in image
But I want image to display like this
Here is the code which gives the 1st image output.
<tr style="background-color: rgb(253, 253, 183); color: rgb(42, 16, 179);font-size: 13px;" >
<td><?php echo $row->eq_application_no; ?></td>
<td><?php echo $row->eq_class; ?></td>
<td><?php echo $row->eq_name;?></td>
<td><?php echo $row->mid_name; ?></td>
<td><?php echo $row->last_name; ?></td>
<td><?php echo $row->eq_sex; ?></td>
<td><?php echo $row->father_name; ?></td>
<td><?php echo $row->eq_dob; ?></td>
<td><?php echo $row->age.",".$row->month.",".$row->day;?></td>
<td><?php echo $row->scat_id;?></td>
<td><?php echo $row->parent_cate_id;?></td>
<td><?php echo $row->no_of_transfer;?></td>
<td><?php echo $tc_case; ?></td>
<td><?php echo$row->last_school_type; ?></td>
<td><?php echo $row->eq_prv_acdmic;?></td>
<td><?php if($row->kv_tc_date=="1970-01-01"){echo "-";}else{echo $row->kv_tc_date;}?></td>
<td><?php echo $row->kv_tc_no;?></td>
<td><?php echo $row->last_class_cgpa;?></td>
<!--value="Edit"-->
<td><input type="button" id="<?php echo $row->es_enquiryid;?>" onclick="edit_record(<?php echo $row->es_enquiryid;?>)" style="background-image:url(images/edit24.png);width:24px;height:24px;"></td><td>
<!--value="Delete"-->
<input type="button" id="<?php echo $row->es_enquiryid;?>" onclick="delete_record(<?php echo $row->es_enquiryid;?>)" style="background-image:url(images/delete24.png);width:24px;height:24px;" ></td><td><?php
if($eligible=="Y")
{?><input type="checkbox" class="app" name="app[]" d="
<?php echo $row->es_enquiryid;?>" value="<?php echo $row->es_enquiryid;?>">
<?php }
else
{
echo"-";
}
?></td>
</tr>
<?php } ?>
</tbody>
</table>
<table>
<tr>

Add image directly then:
<img src="images/delete24.png" id="<?php echo $row->es_enquiryid;?>" onclick="delete_record(<?php echo $row->es_enquiryid;?>)" style="cursor:pointer;width:24px;height:24px;" />

Related

How can i use the a tag

I have some code and would like to add an hyperlink to each entry on my database
tried using the 'a' tag
<tr>
<td><?php echo $row['id']; ?></td>
<td><a href='details.php'><?php echo $row['game_name']; ?></a></td>
<td><?php echo $row['game_year']; ?></td>
<td><?php echo $row['system']; ?></td>
<td style="text-align: center; color:green"><?php echo $row['owned']; ?></td>
<td style="text-align: center; color:blue"><?php echo $row['completed']; ?></td>
<td><?php echo $row['media']; ?></td>
<td><?php echo $row['launcher']; ?></td>
<tr>
would like to be able to link to a details page
<a href='details.php?gameID=<?=$row['id']?>'>
And in your details.php page you could fetch your DB:
$gameID = (int)$_GET['gameID'] and a bit more error handling

Do While with IF

i just want data will show if ['stt']==1
Here is the code :
<?php do { ?>
<tr>
<td><?php echo $row_daftaruser['id']; ?></td>
<td><?php echo $row_daftaruser['nama']; ?></td>
<td><?php echo $row_daftaruser['email']; ?></td>
<td><?php echo $row_daftaruser['username']; ?></td>
<td><?php echo $row_daftaruser['password']; ?></td>
<td><?php echo $row_daftaruser['alamat']; ?></td>
<td><?php echo $row_daftaruser['tgl_lahir']; ?></td>
<td><?php echo $row_daftaruser['stt']; ?></td>
</tr>
<?php } while ($row_daftaruser = mysql_fetch_assoc($daftaruser)); ?>
Can somebody help me?
you could try this:
<?php do { ?>
<?php if($row_daftaruser['stt'] == 1): ?>
<tr>
<td><?php echo $row_daftaruser['id']; ?></td>
<td><?php echo $row_daftaruser['nama']; ?></td>
<td><?php echo $row_daftaruser['email']; ?></td>
<td><?php echo $row_daftaruser['username']; ?></td>
<td><?php echo $row_daftaruser['password']; ?></td>
<td><?php echo $row_daftaruser['alamat']; ?></td>
<td><?php echo $row_daftaruser['tgl_lahir']; ?></td>
<td><?php echo $row_daftaruser['stt']; ?></td>
</tr>
<?php endif ?>
<?php } while ($row_daftaruser = mysqli_fetch_assoc($daftaruser)); ?>
This code will only display values if stt is equal to 1.
Also, use mysqli not mysql because it mysql is obsolete.
Why do not you write the query this way?
SELECT * FROM TABLE WHERE stt = 1;

Loop php values from an echo in HTML

I have a little issue when I try to to loop my php values in HTML. So far this is what I tried but I have not excpected result.
If I remove the loop I only get the first entry. I would like to echo all the possibles entries from my research.
This is my code ( from an SQL request).
<html>
<table>
<tr>
<th>Name</th>
<th>Surname</th>
<th>Number</th>
<th>Adress</th>
<th>link</th>
<!--<th class="glyphicon glyphicon-pencil"></th>-->
</tr>
<tr>
<?php $rowG = oci_fetch_array($stid, OCI_RETURN_NULLS);?>
<?php foreach($array as $rowG=>$value): ?> <tr>
<td><?php echo $rowG[2]; ?></td>
<td><?php echo $rowG[1]; ?></td>
<td><?php echo $rowG[0]; ?></td>
<td><?php echo $rowG[3]?></td>
<td><?php echo "<a href='./consultation.php?Login=$rowG[2]'> Link </a>" ; ?></td>
<?php endforeach;}} ?>
</tr>
</table>
</html>
Do you know where I made my mistake ?
Thank you for your help
Edit : Finally I managed to do it by using a do{}while loop.
Thank you all for your help
RFlow
It's hard to guess what you are trying to do or even what actually happens, since I don't know what is assigned to $rowG, so I tried to hack meaning out of this from the code's errors and came up with that :
<?php
while ($rowG = oci_fetch_array($stid, OCI_RETURN_NULLS)) {
?>
<tr>
<td><?php echo $rowG[2]; ?></td>
<td><?php echo $rowG[1]; ?></td>
<td><?php echo $rowG[0]; ?></td>
<td><?php echo $rowG[3]; ?></td>
<td><?php echo ' Link '; ?></td>
</tr>
<?php
}
?>
If it doesn't work with you, you'll have to provide the informations that should have been included in your question since the begining.
This is basic iteration over query results:
while ($rowG = oci_fetch_array($stid, OCI_RETURN_NULLS)) {?>
<tr>
<td><?php echo $rowG[2]; ?></td>
<td><?php echo $rowG[1]; ?></td>
<td><?php echo $rowG[0]; ?></td>
<td><?php echo $rowG[3]?></td>
<td><?php echo "<a href='./consultation.php?Login=$rowG[2]'> Link </a>" ; ?></td>
</tr>
<?php
}
<?php foreach($array as $rowG=>$value): ?> <tr>
<td><?php echo $rowG[2]; ?></td>
<td><?php echo $rowG[1]; ?></td>
<td><?php echo $rowG[0]; ?></td>
<td><?php echo $rowG[3]?></td>
<td><?php echo "<a href='./consultation.php?Login=$rowG[2]'> Link </a>" ; ?></td>
<?php endforeach;}} ?>
Would be :
<?php foreach($rowG as $arr): ?> <tr>
<td><?php echo $arr[2]; ?></td>
<td><?php echo $arr[1]; ?></td>
<td><?php echo $arr[0]; ?></td>
<td><?php echo $arr[3]?></td>
<td><?php echo "<a href='./consultation.php?Login=$arr[2]'> Link </a>" ; ?></td>
<?php endforeach;}} ?>
Note the use of $arr instead of $rowG.
In the original code $array is not used.

How to open file by using windowpopup

I have file (feeColect.php) which display information by using php, now I want to run (stockreportPDF.php) file after click Export PDF button, its real confuse me that what is wrong with the code while I used the same on previous project
1: this is (feeColect.php) file.
<tr><td><?php echo $list->idnumber; ?></td>
<td><?php echo $list->name; ?></td>
<td><?php echo $list->class; ?></td>
<td><?php echo $list->boarding_fee; ?></td>
<td><?php echo $list->school_fee; ?></td>
<td><?php echo $list->trans_fee; ?></td>
<td><?php echo $balance; ?></td>
<td><?php echo $list->term; ?></td>
<input type="hidden" name="id" id="id" value="<?php echo $list->id; ?>">
<?php $url_PDFstock ="stockreportPDF.php?from_date=$from_date&to_date=$to_date "; ?>
this is button that it suppose to open windowpop after click
<?php echo "<p> <a onclick=\"return windowpop('". $url_PDFstock ."')\">
<input class='btn btn-round btn-orange' type='button' value='Export PDF'></a></p>";?>

checkbox error in cakephp

<?php
$i= 0;
foreach($purchaseorder as $tdata):
$i++;
?>
<tr >
<td><?php echo $tdata['pay_date']; ?></td>
<td><?php echo $tdata['cylinder']; ?></td>
<td><?php echo $tdata['amount']; ?></td>
<td><?php echo $tdata['rtgs_no']; ?></td>
<td><?php echo $tdata['cheque_no']; ?></td>
<td><?php echo $tdata['dd_no']; ?></td>
<td><?php echo if ($tdata['approve']=='true')
{
?>
<img src="/../img/green.png" alt="alt-tag"/>;
<?php
}
else
{
?>
<img src="/../img/red.png" alt="alt-tag" />;
<?php } ?></td>
</tr>
<?php
endforeach;
?>
my code is when i check a checkbox and submit a green tick should be displayed in list page..if its not checked and submitted a red cross should be displayed..but i get a error in the above code..what sholud i do?
<td><?php if ($tdata['approve']=='true')
{ ?>
<img src="/../img/green.png" alt="alt-tag"/>
<?php }
else
{ ?>
<img src="/../img/red.png" alt="alt-tag" />
<?php } ?></td>
<?php
foreach($purchaseorder as $tdata):
?>
<tr >
<td><?php echo $tdata['pay_date']; ?></td>
<td><?php echo $tdata['cylinder']; ?></td>
<td><?php echo $tdata['amount']; ?></td>
<td><?php echo $tdata['rtgs_no']; ?></td>
<td><?php echo $tdata['cheque_no']; ?></td>
<td><?php echo $tdata['dd_no']; ?></td>
<td><?php if($tdata['approve']==true)
{
?>
<img src="/../img/green.png" alt="alt-tag"/>;
<?php
}
else
{ ?>
<img src="/../img/red.png" alt="alt-tag" />;
<?php
} ?>
</td>
</tr>
<?php
endforeach;
?>
try this code and if possible show me the data thats comes on "$purchaseorder" variable
First make var_dump($tdata) and look 'approve' index value. If is set $tdata['approve'] then change code:
<td><?php if ($tdata['approve']=='true')
{ ?>
<img src="/../img/green.png" alt="alt-tag"/>
<?php }
else
{ ?>
<img src="/../img/red.png" alt="alt-tag" />
<?php } ?></td>
for this
<?php
$approveImg = ($tdata['approve']=='true') ? 'green.png' : 'red.png';
?>
<td>
<img src="/../img/<?=$approveImg?>" alt="alt-tag"/>
</td>
Also check paths to images

Categories