Jump to content

[SOLVED] count problams cheers


redarrow

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>

Archived

This topic is now archived and is closed to further replies.

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