Page 1 of 1

while statment with 2 different db query's

Posted: Sun Jan 18, 2004 12:02 pm
by funsutton
I can only generate the $datarow['c'] and not the $row['Files']; Isn't there a way to do 2 while conditions at the same time? I need the result to be formatted in 2 separate columns. Thanks!

Code: Select all

<?
	include "dbconnect.php";
	$query = "SELECT * FROM Briansutton_Files";
	$result = mysql_query($query) or die(mysql_error());
	$dataquery = "SELECT *, COUNT(*) AS c FROM Briansutton_Log GROUP BY Page";
	$dataresult = mysql_query($dataquery) or die(mysql_error());
	echo "<table border=1>";

	while($row = mysql_fetch_assoc($result) && $datarow = mysql_fetch_assoc($dataresult))
	{ 
    echo "<td nowrap><font size=1 face=arial>".$row['Files']."</td>";
    echo "<td nowrap><font size=1 face=arial>".$datarow['c']."</td></tr>";
	}
	echo "</table>";
?>

Posted: Sun Jan 18, 2004 12:42 pm
by phpcoder

Code: Select all

$query = "SELECT * FROM Briansutton_Files";
If "Files" is the name of database field the instead of this query use this one

Code: Select all

$query = "SELECT Files FROM Briansutton_Files";

Posted: Sun Jan 18, 2004 12:49 pm
by funsutton
Each query will work on their own. I did as you suggested, but it still only outputs the $datarow...

perhaps it isn't possible to do 2 while statements at the same time.

Posted: Sun Jan 18, 2004 1:22 pm
by phpcoder
try to execute result of queries separtely

Code: Select all

while($row = mysql_fetch_assoc($result) )
&#123;
your codr 
&#125;
while(datarow = mysql_fetch_assoc($dataresult)) )
&#123;
your code 

&#125;
check u r getting any result from both queries .

Posted: Sun Jan 18, 2004 4:46 pm
by funsutton
Yeah, that doesnt work either...a nested while statement will complete the inner one first and then do the outter one.

Posted: Mon Jan 19, 2004 2:46 am
by phpcoder
Then i think u r not getting data from database in $row['Files']. just apply this query directly on ur table thro phpMyadmin then c what happen i think u r not getting data from this table.