PDM Posted July 27, 2004 Share Posted July 27, 2004 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. ??? Quote Link to comment Share on other sites More sharing options...
PDM Posted July 28, 2004 Author Share Posted July 28, 2004 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)); ?> Quote Link to comment Share on other sites More sharing options...
PDM Posted July 28, 2004 Author Share Posted July 28, 2004 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???? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.