dosser Posted May 24, 2006 Share Posted May 24, 2006 Hi guys, hope you can help me with this.I have set up my mysql database and several php pages to view and enter data. All working fine. I discovered a problem when I came to try to produce a list of all entries as links. I then realised that any queries I entered in the 'browse.php' page (which issues a query to the DB and shows the results in a table), although returned the correct results, never actually altered the url. I.E was always ...localhost/browse.php (i.e. missing any ?id=3 etc). If I try to just type in the url eg ....browse.php?id=3 the entire contents of the database is returned. Anyone have any ideas what the problem could be? Quote Link to comment https://forums.phpfreaks.com/topic/10354-phpid-url-problem/ Share on other sites More sharing options...
zq29 Posted May 24, 2006 Share Posted May 24, 2006 Its quite hard to debug when we can't see the code! Fancy posting it up? Quote Link to comment https://forums.phpfreaks.com/topic/10354-phpid-url-problem/#findComment-38590 Share on other sites More sharing options...
dosser Posted May 24, 2006 Author Share Posted May 24, 2006 browse.php$recipe=addslashes($_POST[recipe]);$result=@mysql_query("select recipe_name, restaurant_info,chef_name from recipes,restaurant,chefs where recipes.recipe_id=restaurant.recipe_id and chefs.chef_id=restaurant.chef_id and recipe_name like '%$recipe%' order by restaurant_id");if(!$result) {echo("<p>Error performing query: " . mysql_error() ."</p>"); exit();} while ($row = mysql_fetch_array($result) ) { echo("<table border= \"2\" align= \"center\" width=\"900\" cellpadding=\"7\" ><tr><th width\"20\%\">Recipe</th><th width=\"60\%\">Restaurant</th><th width=\"20\%\">Chef</th></tr><tr align= \"center\"><td>" . $row["recipe_name"] . " </td><td> " . $row["restaurant_info"] . " </td><td> " . $row["chef_name"] . " </td></tr></table>" );} So this creates a table with the correct info when i search a recipe name from search.html<form action="browse.php" method="post">Name:<input type="text" name="recipe" size="50"><input type="submit" value="submit"><input type="reset" name="reset" value="reset">I am looking for 2 things. a) That in the table above, I can click on eg $row["restaurant_info"] and it will research and provide all info for that restaurant and produce a similar table with the results. (At moment I have a separate page called searchrest.html and browserest.php which do exactly the same as above but searching for restaurants instead. I think I could combine them using OR in the query but that doesnt matter for now). b) How do I create a list of all entries in the database as links, that when clicked would produce a table with the results as above.Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/10354-phpid-url-problem/#findComment-38605 Share on other sites More sharing options...
dosser Posted May 24, 2006 Author Share Posted May 24, 2006 I should add that here is the script I tried to use for listing all the entries in the eg recipe table. I can get a list of the recipes, appearing as links, but then when I click on one, instead of outputting the table with just that one recipe, the entire database is listed.$sql_query = "SELECT * FROM recipes";$result = mysql_query($sql_query);if(mysql_num_rows($result)){while($row = mysql_fetch_row($result)){echo ("<a href=\"browse.php?recipe_id=$row[0]\">$row[1]</a>");}}else{echo "no values in the database";} Quote Link to comment https://forums.phpfreaks.com/topic/10354-phpid-url-problem/#findComment-38616 Share on other sites More sharing options...
urbandsigns.com Posted May 24, 2006 Share Posted May 24, 2006 I would send it to a new page once the link is clicked. Then do a select where ID = $ID and it will display just the information about that 1 restaurant. Does that help or am I reading your question wrong? Quote Link to comment https://forums.phpfreaks.com/topic/10354-phpid-url-problem/#findComment-38632 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.