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
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?

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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