Hi!This is my 1st thread.
I wanted to ask that I have a common table for clients.If client is given quotation, hes status is 1, if given invoice, hes status is 2 and so on.
If i want to display only the clients who have received the invoice, I fire qury like:

"SELECT existing_clients.exi_workesti_date, existing_clients.exi_work_price, client_master.client_name FROM existing_clients LEFT JOIN client_master
ON existing_clients.client_id=client_master.client_id WHERE MONTH(exi_quo_date) = MONTH(CURDATE()) ORDER BY existing_clients.exi_quo_date ASC"

I have a client master for all my clients.But when I try to display the report of the clients, single client is displayed again and again in all categories and 0 amount and wrong date is displayed. Can anyone tell me how I can display the result only if the data is found in the database related to current status only?And I want to display "NO RECORDS" message is data is not found.
My overall code is:
$query=mysql_query("SELECT existing_clients.exi_workesti_date, existing_clients.exi_work_price, client_master.client_name FROM existing_clients LEFT JOIN client_master
ON existing_clients.client_id=client_master.client_id WHERE MONTH(exi_quo_date) = MONTH(CURDATE()) ORDER BY existing_clients.exi_quo_date ASC");
if(mysql_num_rows($query) > 0)
{
while($row=mysql_fetch_array($query))
{
if($row!=0)
{
echo "<tr>
<td class='style3'>"; echo $row; echo "</td>
</tr>
<tr>
<td class='style4'>Rs.&nbsp;"; echo $row; echo "</td>
</tr>
<tr>
<td class='style4'>"; print date('d.m.Y', strtotime($row)); echo "</td>
</tr>";
}
}
}
else
{
echo "<tr>
<td class='style3'>No Records This Month</td>
</tr>";
}

Recommended Answers

All 2 Replies

If you want a specific status, just add it to the WHERE clause of your query.

Next time, please use code tags for readability.

That really worked!
Thanks for ur reply.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.