Jump to content

Need help getting single record from query


Recommended Posts

I'm having trouble figuring out how to select records from my query.

 

<?php
mysql_select_db($database_BA, $BA);
$query_GetPackages = "SELECT * FROM destpackage WHERE DestinationName = 'Lake Guri Resort' ORDER BY PackageName ASC";
$GetPackages = mysql_query($query_GetPackages, $BA) or die(mysql_error());
$row_GetPackages = mysql_fetch_assoc($GetPackages);
$totalRows_GetPackages = mysql_num_rows($GetPackages);
?>

 

I have the above query on a page where I'm using records selected to populate two drop downs.

 

I'd also like to select other fields from this same query based on specific ID column values.

 

For example I'd like to output the Price field for a record in the above query where the ID field = 41.

 

I know I could create another query to do this but I need to do this 6 times for this page and don't want to create 6 times the server load by using 7 queries on the page.

 

I know this should be real simple but I can't seem to formulate a search phrase correctly to get the answer from a forum or web search.

 

???

Link to comment
Share on other sites

Tried this loop but must have something wrong with my if syntax cause it outputs all records value for 'PkgRate'

 
<?php do {
if ($row_GetPackages['PackageName'] == '5 Days Fishing');
echo "$".$row_GetPackages['PkgRate'];    
} while ($row_GetPackages = mysql_fetch_assoc($GetPackages)); 
?>

Link to comment
Share on other sites

Found the if problem.

 

Deleting the ; at the end of the if line fixed that.

 

Another issue now.

 

I need to run this same loop with different select strings and 6 different places on the page.

 

If I try to run the loop a second or third time, at different locations below in the page it fails to return any values.

 

It seems as if I'm only allow to run the loop once per page????

Link to comment
Share on other sites

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.