Jump to content

Menu query / Query parameters passed as embedded links


slj90

Recommended Posts

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.