Thread: sql query
View Single Post
grace1004 grace1004 is offline
Senior Member
grace1004 is on a distinguished road
Posts: 890
Join Date: Dec 2010
Default 04-30-2012, 02:02 AM

The following code is applicable in case the matching result is just one row.

PHP Code:
$user ="a7246488_serg91"
$password "xxxx"
$database ="a7246488_drinks"

$connection mysql_connect($host$user$password) or die ("couldn't connect to server");        
$db mysql_select_db($database$connection) or die("couldn't select database."); 

$name $_POST['term']; //name of the drink entered by a user
$query ="select NAME, INGREDIENTS, INSTRUCTIONS, CATEGORY from a1(1) where NAME = '%$name%'"
$result mysql_query($query) or die ("Couldn't execute the query.");     
// display $result in an array
$row mysql_fetch_array($result);  
$row) { 
'<br>Ingredients: '.$row['Ingredients']; 
'<br>instructions: '.$row['Instructions']; 
'<br>category: '.$row['category']; 
'<br>Image: '.$row['image'];  
else {
"No matching result!";

Last edited by grace1004; 04-30-2012 at 02:12 AM.
Reply With Quote