what i am trying to do:
loading data from mysql database in a table with edit buttons.
what is going wrong:
when clicking on edit buttons it doesn’t load the data on the edit form.
what i have tried:
i tried the following code at home on Firefox and it worked perfectly. but at work it fails to load the data in Firefox in the edit form and in IE clicking the button does nothing.
<?php
echo '<table id="viewAll">';
echo '<tr>';
echo '<th>Product</th>';
echo '<th>Status</th>';
echo '<th>Summary</th>';
echo '<th>Created</th>';
echo '<th>Updated</th>';
echo '<th>Edit</th>';
echo '</tr>';
while ($data=mysqli_fetch_array($result)){
echo '<tr align="center">
<td>'.$data['product'].'</td>
<td>'.$data['status'].'</td>
<td align="left">'.$data['summary'].'</td>
<td>'.$data['created'].'</td>
<td >'.$data['updated'].'</td>';
echo "<td><a href=\"editForm.php?id=$data[id]\" style=\"text-decoration: none\"><input type=\"submit\" value=\"Edit\" /></a></td>";
echo '</tr>';
}#end of while
}#end of if
echo '</table>';
?>
and then i do:
$id=$_GET['id'];
$query="SELECT * FROM tickets WHERE id='$id'";
$result = mysqli_query($db,$query) or die( "My query ($query) generated an error: ".mysql_error());
$data=mysqli_fetch_array($result);
mysqli_close($db);
I use the contents in the data array to load it into the field in the edit form..
unfortunately this doesn’t work in IE. clicking edit button doesn’t do anything. Can somebody please tell me how to fix it? Thanks.
Try using this:
That will mean you can still use a button.
Also, I strongly suggest if you are not using tables for tabular data, find an alternative, such as
<div>s.And remember to sanitise your SQL queries, or you may be susceptible to SQL injection attacks.
(e.g.
$id=$_GET['id'];=>$id=mysqli_real_escape_string($conn, $_GET['id']);where$connis your MySQL connection object).You can search for any of these things on Google.