Jump to content

Recommended Posts

advance thank you, I want to count all the fields that are set to one and show the total

but dosent work any idears please.

 

The below code is showing all the 1 but not as a total cheers

 

<?php

$query1="select message_error.read,message_bookings.read
,message_enquire.read  
from message_error,message_bookings,message_enquire";

$result1=mysql_query($query1)or die("mysql_error()");

while($x=mysql_fetch_assoc($result1)){

if($x['read']==1){

$total=count($x['read'].COUNT_RECURSIVE);

echo $total;
}
 }
?>

Link to comment
https://forums.phpfreaks.com/topic/45294-solved-count-problams-cheers/
Share on other sites

1176 << i get this and there only 33 of them

 

 

and i tried the count built in method like this but didnt work

<?php

$query1="select message_error.read,message_bookings.read
,message_enquire.read as total count($total)  
from message_error,message_bookings,message_enquire";

$result1=mysql_query($query1)or die("mysql_error()");

while($x=mysql_fetch_assoc($result1)){

if($x['read']==1){

echo $x['total'];
}
 }
?>

i am still getting 1176 where there only 33 number ones in the database wiered innit any idear please cheers.

 

is it becouse the database field for read is set as a int dont no?

 

<?php

$query1="select count(*) as total from message_error,message_enquire,message_bookings";

$result1=mysql_query($query1)or die("mysql_error()");

    while($x=mysql_fetch_assoc($result1)){
  
   echo $x['total'];
   }
  
?>

solved the problam this way ok.

 

 



<?php

$query1="select count(*) as totala from message_bookings where message_bookings.read=1";

$result1=mysql_query($query1)or die("mysql_error()");

while($a=mysql_fetch_assoc($result1)){
  
  $a1=$a['totala'];
  }
  ?>

<?php

$query2="select count(*) as totalb from message_error where message_error.read=1";

$result2=mysql_query($query2)or die("mysql_error()");

while($b=mysql_fetch_assoc($result2)){
  
$b1=$b['totalb'];
}
  
?>

<?php

$query3="select count(*) as totalc from message_enquire where message_enquire.read=1";

$result3=mysql_query($query3)or die("mysql_error()");

while($c=mysql_fetch_assoc($result3)){
  
$c1=$c['totalc'];
  }
  ?>

<?php $total_result=$a1+$b1+$c1; ?>

<?php

echo"<table align='center'><tr><td>

Admin You Got $total_result New Mesaages

</tr></td></table>

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.