john_zakaria Posted December 2, 2008 Share Posted December 2, 2008 Now i have this page and in the image part i want to passs the id in the selected row to the page delete.php and after that deleteing this row <a href='delete.php?id='$id'><img src='untitled.jpg' width='10' height='11' border='0' /></a> i want here to set the id to be like the id in the database to use it in the where condition. can anyone help me on how to set the vaiable$id to be like the id in the selected row? but till now i can not pass the id to the next page <? $DBhost = "localhost"; $DBuser = "root"; //$DBpass = "123456"; $DBname = "gateway"; /// 1. create a database connection $connection = mysql_connect($DBhost, $DBuser) or die ("database connect error: " . mysql_error()); //// 2. select a database to use $db_connect = mysql_select_db($DBname, $connection) or die ("database select error: " . mysql_error()); ///// 3. Perform database query $qryp = "SELECT * FROM hotels"; print "qryp: " . $qryp . "<br>"; $result = mysql_query($qryp) or die ("table error: " . mysql_error()); ?> <table border="1"> <tr> <td> ID </td> <td>Hotel </td> <td>Tel</td> <td>Tel2</td> <td>Fax</td> <td>Contact Person</td> <td>E-mail</td> <td>Notes</td> <td></td> </tr> <p> <? $hotel_name=$_POST["hotel_name"]; $tel=$_POST["tel"]; $tel2=$_POST["tel2"]; $fax=$_POST["fax"]; $contact_person=$_POST["contact_person"]; $emal=$_POST["emal"]; $notes=$_POST["notes"]; ?> <? $qryp2="INSERT INTO `hotels` ( `Hotel_Name` , `Tel` , `Tel2` , `Fax` , `Contact_Person` , `E-mail` , `Notes` ) VALUES ( '$hotel_name', '$tel', '$tel2', '$fax', '$contact_person', '$emal', '$notes' )"; $result2 = mysql_query($qryp2); ///// 3. Perform database query $qryp = "SELECT * FROM hotels"; print "qryp: " . $qryp . "<br>"; $result = mysql_query($qryp) or die ("table error: " . mysql_error()); //// 4. Use returned data while ($tr_res = mysql_fetch_array($result)){ echo "<tr>"; echo "<td>" . $tr_res['id'] . "</td> <td>" . $tr_res["Hotel_Name"] . "</td> <td>" . $tr_res["Tel"] . "</td> <td>" . $tr_res["Tel2"] . "</td> <td>" . $tr_res["Fax"] . "</td> <td>" . $tr_res["Contact_Person"] . "</td> <td>" . $tr_res["E-mail"] . "</td> <td>" . $tr_res["Notes"] . "</td> <td> <a href='delete.php?id='$id'><img src='untitled.jpg' width='10' height='11' border='0' /></a></td> "; echo "</tr>"; } echo("</table>"); ?> Link to comment https://forums.phpfreaks.com/topic/135119-php-my-sql-problem-need-help/ Share on other sites More sharing options...
gevans Posted December 2, 2008 Share Posted December 2, 2008 Have you though of setting the id in a session? Link to comment https://forums.phpfreaks.com/topic/135119-php-my-sql-problem-need-help/#findComment-703876 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.