Forum Moderators: coopster
I've been reading this thread:- [webmasterworld.com...] in relation to this mysql/php tutorial [freewebmasterhelp.com...]
While I've got the script up and running - I am stuck on the last part - trying to get a backend page working. I have an admin page calling a table from the database, and I've added a column with a link to the id ($id) for each row and I want that link to go to the update.php?id=x page for the relevant row.
This is where I'm stuck. The link just says:-
update.php?id=$id - I can't get it to insert the row id in there at all. I have everything else working and made the adjustments as per the advice from vinyljunkie.
I would be most appreciative if someone could please give me a heads up on what I need to do to get this thing going.
Thanks,
Kath
This is the backend edit page code I have so far....
<?
include("somedatabaseinfo.inc.php");
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM tariffs";
$result=mysql_query($query);
$num=mysql_num_rows($result);
$id = $_GET['id'];
mysql_close();
echo "<b><center>Select a Row to Edit</center></b><br><br>";
?>
<table border="1" cellspacing="2" cellpadding="2">
<tr>
<th><font face="Arial, Helvetica, sans-serif">Room Type</font></th>
<th><font face="Arial, Helvetica, sans-serif">No. Nights</font></th>
<th><font face="Arial, Helvetica, sans-serif">Low</font></th>
<th><font face="Arial, Helvetica, sans-serif">Mid</font></th>
<th><font face="Arial, Helvetica, sans-serif">High</font></th>
<th><font face="Arial, Helvetica, sans-serif">Low</font></th>
<th><font face="Arial, Helvetica, sans-serif">Mid</font></th>
<th><font face="Arial, Helvetica, sans-serif">High</font></th>
<th><font face="Arial, Helvetica, sans-serif">Update</font></th>
</tr>
<?
$i=0;
while ($i < $num) {
$roomtype=mysql_result($result,$i,"roomtype");
$numbernights=mysql_result($result,$i,"numbernights");
$cat1low=mysql_result($result,$i,"cat1low");
$cat1mid=mysql_result($result,$i,"cat1mid");
$cat1high=mysql_result($result,$i,"cat1high");
$cat2low=mysql_result($result,$i,"cat2low");
$cat2mid=mysql_result($result,$i,"cat2mid");
$cat2high=mysql_result($result,$i,"cat2high");
$id=mysql_result($result,$i,"id");
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><? echo $roomtype;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $numbernights;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cat1low;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cat1mid;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cat1high;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cat2low;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cat2mid;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><? echo $cat2high;?></font></td>
<td><font face="Arial, Helvetica, sans-serif"><a href="update.php?id=$id"><? echo $id;?></a></font></td>
</tr>
<?
$i++;
}
echo "</table>";