Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
funsutton
Forum Newbie
Posts: 9 Joined: Sun Jan 18, 2004 12:02 pm
Post
by funsutton » Sun Jan 18, 2004 12:02 pm
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>";
?>
phpcoder
Forum Contributor
Posts: 158 Joined: Sat Nov 02, 2002 1:18 pm
Location: Manchester, UK
Post
by phpcoder » Sun Jan 18, 2004 12:42 pm
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";
funsutton
Forum Newbie
Posts: 9 Joined: Sun Jan 18, 2004 12:02 pm
Post
by funsutton » Sun Jan 18, 2004 12:49 pm
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.
phpcoder
Forum Contributor
Posts: 158 Joined: Sat Nov 02, 2002 1:18 pm
Location: Manchester, UK
Post
by phpcoder » Sun Jan 18, 2004 1:22 pm
try to execute result of queries separtely
Code: Select all
while($row = mysql_fetch_assoc($result) )
{
your codr
}
while(datarow = mysql_fetch_assoc($dataresult)) )
{
your code
}
check u r getting any result from both queries .
funsutton
Forum Newbie
Posts: 9 Joined: Sun Jan 18, 2004 12:02 pm
Post
by funsutton » Sun Jan 18, 2004 4:46 pm
Yeah, that doesnt work either...a nested while statement will complete the inner one first and then do the outter one.
phpcoder
Forum Contributor
Posts: 158 Joined: Sat Nov 02, 2002 1:18 pm
Location: Manchester, UK
Post
by phpcoder » Mon Jan 19, 2004 2:46 am
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.