Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

=\ I need help with a Query

$
0
0

Hi, go easy on me please, I am not a pro and I am more than likely doing this the incorrect way. 

$date = date('Y-m-d 07:00:00', strtotime('-24 hours'));
$getJobs = mysql_query("SELECT * FROM jobs WHERE status='1' AND dateofenquiry>='$date'");

while ($row = mysql_fetch_array($getJobs)){
	$clientName = $row['name'];
	$jobID = $row['jobID'];

	$getNotes = mysql_query("SELECT * FROM notes WHERE jobID='$jobID'");

	if (mysql_num_rows($getNotes) == '0'){
		$getJobsa = mysql_query("SELECT * FROM jobs WHERE status='1' AND dateofenquiry>='$date'");
		$TotalNew = mysql_num_rows($getJobsa);
	}

So this is a snippet of my code, I have a query $getJobs and it runs a fetch array I get the number of notes from another table and then If the job has 0 notes then send me an email, Where it is going wrong is $getJobsa and count rows, My table within the last 24 hours has 6 jobs. But only 1 should be showing as only 1 has 0 notes. But my email says 6 when I echo $TotalNew it shows all of them, I know it's within my query but I don't know how to count the notes and put it in a query. 

 

My question is how do I count the number of rows with the jobID as notes and add it to the 1 query?


Viewing all articles
Browse latest Browse all 13200

Trending Articles