RE: [PHP-DB] First record in a search

2005-02-04 Thread Bastien Koert
hm, that should be mysql_num_rows==0
if (($row = mysql_num_rows($result)) == 0)
{
$member_list = "Sorry, we do not have any translators for $_POST[language]";
}
bastien
From: Novice Learner <[EMAIL PROTECTED]>
To: PHP Mailing List 
Subject: [PHP-DB] First record in a search
Date: Fri, 4 Feb 2005 21:02:56 -0800 (PST)
Hello,
I have the following code and I am searching records from a table. I am 
getting all the results, but when I "un"comment the  lines I do not get the 
first record from the search result. I want to have those comment lines 
executing when no records are found, I want to display a message.

I am searching from seven fields: native, from1, to1, from2, to2, from3 and 
to3, these fields have lanage names. Any help would be appreciated.


$sql = "SELECT
user_id, fname, mi, lname, native, from1, to1, from2, to2, from3, to3
fm memberinfo
WHERE native='$_POST[language]' OR from1='$_POST[language]' OR 
to1='$_POST[language]'
OR from2='$_POST[language]' OR to2='$_POST[language]' OR 
from3='$_POST[language]'  OR from3='$_POST[language]'
ORDER BY lname"  ;

$result = @mysql_query($sql, $connection) or die(mysql_error());
/*
if (($row = mysql_fetch_array($result)) == 0)
{
 $member_list = "Sorry, we do not have any translators for 
$_POST[language]";
}
*/

$member_list = "";
while ($row = mysql_fetch_array($result))
{
$user_id = $row['user_id'];
$fname = $row['fname'];
$lname = $row['lname'];
$native = $row['native'];
$from1 = $row['from1'];
$to1 = $row['to1'];
$from2 = $row['from2'];
$to2 = $row['to2'];
$from3 = $row['from3'];
$to3 = $row['to3'];
$member_list .= "$lname, 
$fname";
}
$member_list .= "";

?>

-
Do you Yahoo!?
 The all-new My Yahoo! – What will yours do?
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[PHP-DB] First record in a search

2005-02-04 Thread Novice Learner
Hello,
 
I have the following code and I am searching records from a table. I am getting 
all the results, but when I "un"comment the  lines I do not get the first 
record from the search result. I want to have those comment lines executing 
when no records are found, I want to display a message. 
 
I am searching from seven fields: native, from1, to1, from2, to2, from3 and 
to3, these fields have language names. Any help would be appreciated.
 

$sql = "SELECT
user_id, fname, mi, lname, native, from1, to1, from2, to2, from3, to3 
from memberinfo 
WHERE native='$_POST[language]' OR from1='$_POST[language]' OR 
to1='$_POST[language]'
OR from2='$_POST[language]' OR to2='$_POST[language]' OR 
from3='$_POST[language]'  OR from3='$_POST[language]'
ORDER BY lname"  ;

$result = @mysql_query($sql, $connection) or die(mysql_error());
 
/*
if (($row = mysql_fetch_array($result)) == 0)
{
 $member_list = "Sorry, we do not have any translators for $_POST[language]";
}
*/
 

$member_list = "";
while ($row = mysql_fetch_array($result))
{
$user_id = $row['user_id'];
$fname = $row['fname'];
$lname = $row['lname'];
$native = $row['native'];
$from1 = $row['from1'];
$to1 = $row['to1'];
$from2 = $row['from2'];
$to2 = $row['to2'];
$from3 = $row['from3'];
$to3 = $row['to3'];

$member_list .= "$lname, 
$fname";
}
$member_list .= "";
 

?>



-
Do you Yahoo!?
 The all-new My Yahoo! – What will yours do?