Jump to content

What is wrong with my query?


marukochan

Recommended Posts

Can someone point out to me what is wrong with this code?

 

It suppose to print out the company id with "Awarded" status, but instead it prints out ALL the company id regardless it is "Awarded" or "Bidding".

 

$status = "Awarded";
$query = mysql_query ("SELECT * FROM project WHERE project_status = '$status'");
$result= mysql_num_rows($query);

while($row=mysql_fetch_array($query))
{
print $row["company_id"];
echo ("<br>");
}

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/68185-what-is-wrong-with-my-query/
Share on other sites

With this data

[pre]

id, company_id, project_status

1,      1,      'Awarded'

2,      2,      'Bidding'

3,      3,      'Awarded'

4,      4,      'Bidding'

[/pre]

 

your code gave

 

1

3

 

So I'd check your data

 

 

@beeboo

if the query result is in $query, why  do you suggest using $result, which would contain the number of rows?

while($row=mysql_fetch_array($query)) this query gives error like this

Warning: Supplied argument is not a valid MySQL result resource in c:\apache\htdocs\adminajax\home1.php on line 352

 

so he is not found any result

and sceond qus. is when arise when query gives any result

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.