Link to home
Start Free TrialLog in
Avatar of Patrick Martin
Patrick MartinFlag for United States of America

asked on

PHP echo sql result

I'm not able to get the result of the second query $Result to echo out, what am I missing?

Thanks in advance


$sqlstr = mysql_query("SELECT * FROM Roster");
while($row=mysql_fetch_array($sqlstr)){

$Result = mysql_query("Select Count(*) AS 1stMain from Race_Results where `1` = ".$row['Car_Number']."");


echo "<table border=0 align='center'>";
echo "</td><td rowspan=8>";
echo $row['Image'];
echo "</td><th width=300>";
echo "<u>Details</u>";
echo "</th>";
echo "<th width=300>";
echo "<u>YTD Stats</u>";
echo "</th>";
echo "<th width=300>";
echo "<u>Overall Stats</u>";
echo "</th></tr><tr><td>";
echo "<b>Car Number: </b>" .$row['Car_Number'];
echo "</td><td>";
echo "<b>1st in Main: </b>" .$Result;
echo "</td><td>";
echo "<b>1st in Main: </b>";

Open in new window

Avatar of szewkam
szewkam
Flag of Poland image

it's because you didn't fetch the result.
try
list($Result) = mysql_fetch_row(mysql_query("Select Count(*) AS 1stMain from Race_Results where `1` = ".$row['Car_Number'].""));
Try this query:

$Result = mysql_query("Select Count(*) AS 1stMain from Race_Results where `1` = '".$row['Car_Number']."'");


Hope this helps,
Addy
and then after add this line:


$data  = mysql_fetch_row($Result);

So with this line you will get the row you want..

Hope this helps,
Addy
Avatar of Patrick Martin

ASKER

szewkam - no change

addywatson - I get "array" outputed
$Result = mysql_query("Select Count(*) AS 1stMain from Race_Results where `1` = '".$row['Car_Number']."'");
$data  = mysql_fetch_row($Result);


echo "<b>1st in Main: </b>" .$data;

Open in new window

SOLUTION
Avatar of szewkam
szewkam
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Andyc75 - It works, that's the way I started but I guess my query was wrong from the get go. This would allow me to pull more results at once as well which I will need to do, then I can just call out the columns that I need.

Thanks!