phpnewbie1979 Posted March 6, 2010 Share Posted March 6, 2010 I am having a difficult time getting values to pass through the URL. I need to create two pages, one that list the names of neighborhoods and link to the second page, which will show the rest of the information for each neighborhood. The problem I'm having is that the values aren't passing to the second page. Instead of getting http://www.sitename.com/detail.php?id=1, what I'm getting is http://www.sitename.com/detail.php?id=$id. I can't figure out what I'm doing wrong. If anyone can point me in the right direction that would be great. Page 1 code is <?php require_once "connect_to_mysql.php"; $query="SELECT id, name FROM table ORDER BY name"; $result=mysql_query($query); $num=mysql_num_rows($result) or die(mysql_error()); ?> <table border="0" cellspacing="0" cellpadding="0"> <?php $i=0; while ($i <$num) { $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); ?> <tr> <td><a href='detail.php?id=$id'><?php echo $name; ?></a></td> </tr> <?php $i++; } ?> </table> Page 2 code is: <?php require_once "connect_to_mysql.php"; $query = "SELECT * FROM table WHERE id=".$_GET['id']; $result=mysql_query($query); while($row = mysql_fetch_array($result)){ $name = $row["name"]; $fieldtwo = $row["fieldtwo"]; } ?> <?php echo $name; echo $fieldtwo; ?> Link to comment https://forums.phpfreaks.com/topic/194365-help-passing-values-through-url/ Share on other sites More sharing options...
inversesoft123 Posted March 6, 2010 Share Posted March 6, 2010 <?php require_once "connect_to_mysql.php"; $query="SELECT id, name FROM table ORDER BY name"; $result=mysql_query($query); $num=mysql_num_rows($result) or die(mysql_error()); ?> <table border="0" cellspacing="0" cellpadding="0"> <?php $i=0; while ($i <$num) { $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); ?> <?php echo "<tr><td><a href=\"detail.php?id=$id\">$name</a></td></tr>"; $i++; } ?> </table> Updated Link to comment https://forums.phpfreaks.com/topic/194365-help-passing-values-through-url/#findComment-1022446 Share on other sites More sharing options...
phpnewbie1979 Posted March 6, 2010 Author Share Posted March 6, 2010 thank you so much. Link to comment https://forums.phpfreaks.com/topic/194365-help-passing-values-through-url/#findComment-1022448 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.