Click here to Skip to main content
15,895,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Doing the query on the database it gets the correct results, but the table is empty. Any suggestion?
HTML
<TABLE>

PHP
<?php

$userid=$_SESSION['userid'];

$result=mysql_query("SELECT * FROM companies WHERE company='$_GET[company]' and car_moto='$_GET[car_moto]' and packet='$_GET[packet]' and userid='$userid'");
$num=mysql_num_rows($result);

$i=0;

while ($i < $num) {
        $f0=mysql_result($result,$i,"id");
        $f1=mysql_result($result,$i,"company");
        $f2=mysql_result($result,$i,"car_moto");
        $f3=mysql_result($result,$i,"packet");
        $f4=mysql_result($result,$i,"protect");
        $f5=mysql_result($result,$i,"price_protect");
        $f6=mysql_result($result,$i,"clear_protect");

        echo "<tr><td align='center'><span>$f1</span></td><td align='center'><span>$f2</span></td><td align='center'><span>$f3</span></td><td align='center'><span>$f4</span></td><td align='center'><span>$f5</span></td><td align='center'><span>$f6</span></td></tr>";
$i++;

}

?>

HTML
</TABLE>
Posted
Updated 6-Sep-13 2:01am
v3
Comments
ArunRajendra 6-Sep-13 7:31am    
Can you check if its entering while loop. Else I don't see the reason for the table to be empty.

Try adding the following :
PHP
...
echo $result;
$num=mysql_num_rows($result);
echo $num; 
echo $result;
...

and see what $num is and what happens to $result.
 
Share this answer
 
Comments
bmaglar 6-Sep-13 7:38am    
Resource id #30Resource id #3
bmaglar 6-Sep-13 7:48am    
the query works perfect at the database, not echo $result;
I have to add

PHP
<pre>mysql_query("set character set 'utf8'");


before

PHP
$result=mysql_query("SELECT * FROM companies WHERE company='$_GET[company]' and car_moto='$_GET[car_moto]' and packet='$_GET[packet]' and userid='$userid'");


and the table is ok
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900