Jump to content

Its Only Selecting one Record!


Crew-Portal

Recommended Posts

<?php
while ($row = mysql_fetch_array($result)) {
$active = $row['active'];
/**/	# Hours
/**/	$query = "SELECT sum(hours) FROM flights WHERE user_id = $row[user_id]";
/**/	$result=mysql_query($query);
/**/	$blcktime = number_format(mysql_result($result,0));	
/**/	$query = "SELECT sum(minutes) FROM flights WHERE user_id = $row[user_id]";
/**/	$result=mysql_query($query);
/**/	$blckmins = number_format(mysql_result($result,0));	
$intSeconds = ($blcktime*3600)+($blckmins*60);
					$sqlname = "SELECT air_id FROM user WHERE user_id = $row[user_id]"; 
					$resultname = @mysql_query($sqlname,$connection) or die("Ouch! Invalid Charactor On ID Field! You may Only Put Numbers On The ID Field");
					$numname=mysql_num_rows($resultname);
					while ($rowname = mysql_fetch_array($resultname)) {
					$username = $rowname['username'];
					$airline_identnum = $rowname['air_id'];
					}
					$sqlname = "SELECT name,short FROM airlines WHERE air_id = $airline_identnum"; 
					$resultname = @mysql_query($sqlname,$connection) or die("Ouch! Invalid Charactor On ID Field! You may Only Put Numbers On The ID Field");
					$numname=mysql_num_rows($resultname);
					while ($rowname = mysql_fetch_array($resultname)) {
					$airline = $rowname['name'];
					$short = $rowname['short'];
					}
?>

 

Okay this code works fine except its only pulling the first record in the database But when I remove the lines:

<?php
/**/	# Hours
/**/	$query = "SELECT sum(hours) FROM flights WHERE user_id = $row[user_id]";
/**/	$result=mysql_query($query);
/**/	$blcktime = number_format(mysql_result($result,0));	
/**/	$query = "SELECT sum(minutes) FROM flights WHERE user_id = $row[user_id]";
/**/	$result=mysql_query($query);
/**/	$blckmins = number_format(mysql_result($result,0));	
/**/	$intSeconds = ($blcktime*3600)+($blckmins*60);
?>

Then all of a sudden it works and it pulls all of the records again. So the error is in the line of code right ^^^ So if anyone could help. Link to where this is right here

http://24.76.166.219/index.php?page=roster

Link to comment
Share on other sites

by repeating the use of $result it destroys that mysql resource, thus when it finnishes one itteration of the loop the $result has changed and no longer fetches the next item to the array beraking the loop, so use different names for your mysql queries, but your code looks really bloated try combining that into like a few less queries cause it probably takes forver to load

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.