hi,
i am having a problem in search query.
after entrering query in text field i get only value of one row.
he is da structure
Student table
Code:
*********************************************************
student_id student_name student_course student_age
*********************************************************
1 Alex BIT 19
2 Alex SEO 24
3 Najim ADS 23
4 Julius ADS 21
5 Timothy MP 23
6 Alex OS 19
*********************************************************
here is form coding index.php
Code:
<form action="search.php" method="get">
<label>Name:
<input type="text" name="keyword" />
</label>
<input type="submit" value="Search" />
</form>
here is search.php
PHP Code:
<?php
include_once ("connection.php");
$queryitem = trim($_GET['keyword']);
if($queryitem == "")
{
echo "Enter name you are searching for.";
exit();
}
$query = "SELECT * FROM student WHERE student_name LIKE '%$queryitem%'";
$results = mysql_query($query);
if(mysql_num_rows($results) >= 1)
{
$output = "";
while($row = mysql_fetch_array($results))
{
$id = $row['student_id'];
$name = $row['student_name'];
$course = $row['student_course'];
$age = $row['student_age'];
}
$output .=' '.$id.' <br /> '.$name.' <br /> '.$course.' <br /> '.$age.' ';
}
else
$output = 'There was no matching record for the name ' . $queryitem . ';
?>
<html>
<head>
</head>
<body>
<?php echo $output; ?>
</body>
</html>
here the problem occour
if i search for Alex ony one value is displaying like
1
Alex
BIT
19
please help