Jump to content


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


Need help getting single record from query

Recommended Posts

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


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.



Share this post

Link to post
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)); 

Share this post

Link to post
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????

Share this post

Link to post
Share on other sites


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.