RE: First record in a search

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <novicelearner@xxxxxxxxx>
To: PHP Mailing List <php-db@xxxxxxxxxxxxx>
Subject:  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 = "<ul>"; 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 .= "<li><a href=\"show_details.php?lname=$lname\">$lname, $fname</a>";
}
$member_list .= "</ul>";



?>



---------------------------------
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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux