Wayne88
asked on
PHP: If more than 1 match found then list up to 10 as links
Hi,
Given the code below, how can I display the content of mysql_fetch_assoc array? What I would like to present is a list up to say 10 or 20 or all at a time of the matches that were found then display them as link where the user can simply click on it to display the content of the record.
Let's use a good existing code given by cxr for example:
https://www.experts-exchange.com/questions/24005839/Want-to-be-able-to-Add-Edit-and-Search-in-the-same-form-using-PHP-and-mySQL.html?sfQueryTermInfo=1+10+30+arraysg2008
Thanks in advance
Given the code below, how can I display the content of mysql_fetch_assoc array? What I would like to present is a list up to say 10 or 20 or all at a time of the matches that were found then display them as link where the user can simply click on it to display the content of the record.
Let's use a good existing code given by cxr for example:
https://www.experts-exchange.com/questions/24005839/Want-to-be-able-to-Add-Edit-and-Search-in-the-same-form-using-PHP-and-mySQL.html?sfQueryTermInfo=1+10+30+arraysg2008
Thanks in advance
if($_POST['user']=='Search') {
$res = mysql_query(
"select * from $tablename where
firstname like '$firstname%' and
lastname like '$lastname%' and
department like '$department%'
order by id");
if($res) {
$row = mysql_fetch_assoc($res);
if($row) {
$row_count = mysql_num_rows($res);
if($row_count > 1) $msg = $row_count.' rows found, showing the first';
$row_id=$row['id'];
$firstname=$row['firstname'];
$lastname=$row['lastname'];
$department=$row['department'];
} else $msg = 'No rows found';
} else $msg = 'query failed: '.mysql_error();
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
however, both of you did gave me partial ideas that i will be using to accomplish my task. cheers!