Jump to content

Menu query / Query parameters passed as embedded links


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!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.