mysql - Display the amount of Paid items in my database using php -


i using php , mysql create page displays of jobs have in database. data shown table , when row clicked modal window triggers information of clicked job inside. @ top of page want simple counter shows amount of paid jobs, invoiced jobs etc etc. using code below having no luck...

<?php $con = mysql_connect("localhost","databaseusername","password"); if (!$con) { die('could not connect: ' . mysql_error()); } mysql_select_db("databasename", $con);  $result = mysql_query("select count(1) jobslist"); $row = mysql_fetch_array($result);  $total = $row[0];   mysql_close($con); ?> 

this code far aware counting amount of int columns set 1 rather 0. no matter try can't seem count amount of 'paid' items in database or 'invoiced' etc etc.

once count function complete echoing out outcome below:

<?php echo "" . $total;?> 

i sure overlooking simple, appreciated.

edit: table structure included

http://i.stack.imgur.com/hcmjv.png

assuming column called paid restructure query similar following. if needed sum amounts involved requires additional tweaking.

$result = mysql_query("select      ( select count(*) `jobslist` `paid`=1 ) 'paid',     ( select count(*) `jobslist` `paid`=0 ) 'unpaid'     jobslist");  $rows   = mysql_num_rows( $result );  while( $rs=mysql_fetch_object( $result ) ){     $paid=$rs->paid;     $unpaid=$rs->unpaid;      echo 'total: '.$rows.'paid: '. $paid.' unpaid: '.$unpaid; } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -