slj90 Posted January 17, 2010 Share Posted January 17, 2010 I am trying to create a code like the one in this example: http://www.zilmat.com/cwd/phpAcademy/topics/User_Driven_Querying/Examples/mysql/animalContinentMenu.html My code is as follows: <?php //Include the connection details, open $connection and select database include ("connection.php"); //Get the Initial Letter passed $ProductC= $_GET["ProductC"]; // create query $query = "SELECT * FROM Product"; //Check if there is an initial letter if (!$ProductC=="") { //if there is, then amend the query $query = $query." WHERE ProductC = '$ProductC' "; } // execute query $result = mysql_query($query) or die ("Error in query: $query. ".mysql_error()); // see if any rows were returned if (mysql_num_rows($result) > 0) { // yes echo "<table cellpadding=10 border=1>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>".$row['ProductID']."</td>"; echo "<td>".$row['ProductName']."</td>"; echo "<td>".$row['ProductImage']."</td>"; echo "<td>".$row['ProductD']."</td>"; echo "</tr>"; } echo "</table>"; } else { // no // print status message echo "No rows found!"; } ?> I think the URL should be something along the lines of.. /productgrab.php?ProductC=Spirits But this brings up 'Page not found' So I don't know if thats the right URL, seen as part of the code is to display a message if no rows were found. Can you see anything wrong with my code or the URL i am trying? Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/188793-menu-query-query-parameters-passed-as-embedded-links/ Share on other sites More sharing options...
wildteen88 Posted January 17, 2010 Share Posted January 17, 2010 I think the URL should be something along the lines of.. /productgrab.php?ProductC=Spirits Yes that is the correct format for the url. Anything after the ? is called a query string. Quote Link to comment https://forums.phpfreaks.com/topic/188793-menu-query-query-parameters-passed-as-embedded-links/#findComment-996718 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.