Jump to content


Photo

Need help getting single record from query


  • Please log in to reply
2 replies to this topic

#1 PDM

PDM
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 27 July 2004 - 09:51 PM

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.

???

#2 PDM

PDM
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 28 July 2004 - 02:06 AM

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)); 
?>


#3 PDM

PDM
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 28 July 2004 - 03:34 AM

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????




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users