DSTR3 Posted February 1, 2013 Share Posted February 1, 2013 I have a mySQL database. Version 5.0. I have a table that is generated dynaically, this works fine. In the table I have the following fields RestName, Address, Phone, Price, Rating This is the table where the webpage name lies for each restaurant. tblRestaurants RestID 1 RestName Red Place RestPage Red_Place.php I am storing a webpage in the RestPage field. When I click on the RestName field in the table I want the webpage stored in the RestPAge field to come up. Needless to say I need a variable because you never know which restaurant will appear in the table. I have this so far... <td><a href='$row[$RestPage]$RestID=RestID'>$row[RestName]</a></td> but it doesn't seem to be working. I'm new to this so..........I need some direction here. Thank you. Link to comment https://forums.phpfreaks.com/topic/273932-href-link-variable/ Share on other sites More sharing options...
trq Posted February 2, 2013 Share Posted February 2, 2013 We need to see more code so that we can see how exactly this is being used. Variables are not interpolated within single quotes, is that your issue? Link to comment https://forums.phpfreaks.com/topic/273932-href-link-variable/#findComment-1409623 Share on other sites More sharing options...
DSTR3 Posted February 2, 2013 Author Share Posted February 2, 2013 The link shows in the table, but the page doesn't come up. You can see the working (used loosely) example at... http://www.menuhead....eelers/Head.php Then Select City, Boston,Back Bay,American(New) SEARCH Then click on 28 degrees. The link goes nowhere. Here is the mySQL query/php that the table is being built with. <?php include("config.php"); if(!$rs = mysql_query("SELECT tblRestaurants.RestName, tblLocations.CityID, tblLocations.AreaID, tblLocations.CuisineID,tblLocations.RestID, CONCAT(tblLocations.StreetNumber,' ', tblLocations.Street) Address, tblLocations.Phone, tblDetails.Price, tblDetails.Rating FROM tblRestaurants INNER JOIN (tblLocations LEFT JOIN tblDetails ON tblLocations.LocationID = tblDetails.LocationID) ON tblRestaurants.RestID = tblLocations.RestID WHERE tblLocations.CityID='$Doggie' AND tblLocations.AreaID='$Kitty' AND tblLocations.CuisineID='$Pig' ORDER BY tblRestaurants.RestName ASC")) { echo "Cannot parse query"; } elseif(mysql_num_rows($rs) == 0) { echo "No records found"; } else { echo "<table id=\"myTable\" table width=\"720\" class=\"tablesorter\" align=\"Left\" cellspacing=\"0\">\n"; echo "<thead>\n<tr>"; echo "<th>PLACE</th>"; echo "<th>ADDRESS</th>"; echo "<th>PHONE</th>"; echo "<th>PRICE</th>"; echo "<th>RATING</th>"; echo "</tr>\n</thead>\n"; while($row = mysql_fetch_array($rs)) { echo"<tr> <td><a href='$row[$RestPage]$RestID=RestID'>$row[RestName]</a></td> <td>$row[Address]</td> <td>$row[Phone]</td> <td>$row[Price]</td> <td>$row[Rating]</td> </tr>\n"; } echo "</table><br />\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/273932-href-link-variable/#findComment-1409624 Share on other sites More sharing options...
trq Posted February 2, 2013 Share Posted February 2, 2013 Replace: <td><a href='$row[$RestPage]$RestID=RestID'>$row[RestName]</a></td> with: <td><a href='{$row['RestPage']}?RestID={$RestID}'>{$row['RestName']}</a></td> Link to comment https://forums.phpfreaks.com/topic/273932-href-link-variable/#findComment-1409625 Share on other sites More sharing options...
DSTR3 Posted February 2, 2013 Author Share Posted February 2, 2013 Thank you. I did that and now I am getting webpage not found. In storing these pages in the table in the mySQL database, is there a certain way this should be done? Right now its just 28_Degrees.php Is this correct? Its saying this in the address bar... http://www.menuhead.net/Steelers/=RestID Link to comment https://forums.phpfreaks.com/topic/273932-href-link-variable/#findComment-1409629 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.