Page 1 of 1

bo select a

Posted: Thu Jan 08, 2004 8:39 am
by Deddog
Help! Below code should select at least 1200 rows. But my echo statement display the figure 0. Where am i going wrong? Using the latest version of PHP and MYSQL.

cheers,

lee.

Code: Select all

<?php 
Connectlistmail();
$sql = "SELECT user1 FROM lm_users WHERE user2 IN ('BB%', 'BL%', 'CA%', 'CH%', 'CW%', 'FY%', 'L1%', 'L2%', 'L3%', 'L4%', 'L5%', 'L6%', 'L7%', 'L8%', 'L9%', 'LA%', 'LL%', 'M1%', 'M2%', 'M3%', 'M4%', 'M5%', 'M6%', 'M7%', 'M8%', 'M9%', 'OL%', 'PR%', 'WA%', 'WN%') ";
$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
$total = mysql_num_rows($result);
echo $total;
?>

// OR 

<?php 
Connectlistmail();
$sql = "SELECT user1 FROM lm_users WHERE user2 IN ('BB', 'BL', 'CA', 'CH', 'CW', 'FY', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8', 'L9', 'LA', 'LL', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'OL', 'PR', 'WA', 'WN') ";
$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>');
$total = mysql_num_rows($result);
echo $total;
?>
[Edit: Added PHP tags for eyecandy. --JAM]

Posted: Thu Jan 08, 2004 6:24 pm
by JAM
I'm not entirely sure, but;

Code: Select all

$sql = "SELECT sum(user2) IN ('BB', 'BL', 'CA', 'CH', 'CW', 'FY', 'L1', 'L2', 'L3', 'L4', 'L5', 'L6', 'L7', 'L8', 'L9', 'LA', 'LL', 'M1', 'M2', 'M3', 'M4', 'M5', 'M6', 'M7', 'M8', 'M9', 'OL', 'PR', 'WA', 'WN') FROM lm_users";
$result = mysql_query($sql) or die(mysql_error().'<p>'.$sql.'</p>'); 
echo mysql_result($result,0);
In returns 0 or 1. So sum() would sum up the results.