0
<?php
if(isset($_POST['ActivityId']))
{
require_once('database.php');
$Search=$_POST['Search'];
$query="select * from registration where Flag='A' AND Activity like '%,$Search,%'";
$result=mysqli_query($dbc,$query) or die('Not Connected');
while($row=mysqli_fetch_array($result))
{
echo "<table border='2'><tr><td> Name--".$row['Name']."</td>
<td>Contact Number--".$row['ContactNumber']."</td>
<td>Email--".$row['Email']."</td>
<td>Address--".$row['Address']."</td></tr></table>";
}
}
elseif(isset($_POST['EventId'])){
require_once('database.php');
$Search=$_POST['Search'];
$query="select * from participation where EventId ='$Search'";
$result=mysqli_query($dbc,$query) or die('Not Connected');
while($row=mysqli_fetch_array($result)){
$LoginId= $row['LoginId'];
echo $LoginId;}
$query="select * from registration where LoginId='$LoginId'";
$result=mysqli_query($dbc,$query) or die('Not Connected to Reg');
while($row=mysqli_fetch_array($result)){
echo "<table border='2'><tr><td> Name--".$row['Name']."</td>
<td>Contact Number--".$row['ContactNumber']."</td>
<td>Email--".$row['Email']."</td>
<td>Address--".$row['Address']."</td></tr></table>";
}}

elseif(isset($_POST['Location']))
{
require_once('database.php');
$Search=$_POST['Search'];
$query="select * from registration where Flag='A' AND Address like '%$Search%'";
$result=mysqli_query($dbc,$query) or die('Not Connected');
while($row=mysqli_fetch_array($result))
{
echo "<table border='2'><tr><td> Name--".$row['Name']."</td>
<td>Contact Number--".$row['ContactNumber']."</td>
<td>Email--".$row['Email']."</td>
<td>Address--".$row['Address']."</td></tr></table>";
}
}

elseif(isset($_POST['BloodGroup']))
{
require_once('database.php');
$Search=$_POST['Search'];
$query="select * from registration where Flag='A' AND BloodGroup ='$Search'";
$result=mysqli_query($dbc,$query) or die('Not Connected');
while($row=mysqli_fetch_array($result))
{
echo "<table border='2'><tr><td> Name--".$row['Name']."</td>
<td>Contact Number--".$row['ContactNumber']."</td>
<td>Email--".$row['Email']."</td>
<td>Address--".$row['Address']."</td></tr></table>";
}
}
?>
<html><body><form action='<?php echo $_SERVER['PHP_SELF']?>' method="post">
<input type="text" name="Search"><br>
<input type="submit" name="ActivityId" value="Submit Activity Id"><br>
<input type="submit" name="EventId" value="Submit Event Id"><br>
<input type="submit" name="Location" value="Submit Location"><br>
<input type="submit" name="BloodGroup" value="Submit Blood Group"><br>

</form>
</body></html>

Hi frds.............
I have two tables named "registration" and "participation". Registration table have some columns like "LoginId", "email","contact no.", "Name" etc.and participation table have 2 column named "LoginId" and "EventId".
Now if user enters EventId, I want to display the details like email,contact no. etc.
I have a code but it not works properly.......
If result have more than one row it only displays the email and contact no. of last one instead of all.
Plzzzzzzzzz help anyone...................
????????/

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by vibhaJ
0

Your while loop is not proper.
See below code.

elseif(isset($_POST['EventId'])){

	require_once('database.php');
	$Search=$_POST['Search'];
	$query="select * from participation where EventId ='$Search'";
	$result=mysqli_query($dbc,$query) or die('Not Connected');
	while($row=mysqli_fetch_array($result))
	{
		$LoginId= $row['LoginId'];
		echo $LoginId;
		$query="select * from registration where LoginId='$LoginId'";
		$resultReg=mysqli_query($dbc,$query) or die('Not Connected to Reg');
		while($rowReg=mysqli_fetch_array($resultReg))
		{
			echo "<table border='2'><tr><td> Name--".$rowReg['Name']."</td>
			<td>Contact Number--".$rowReg['ContactNumber']."</td>
			<td>Email--".$rowReg['Email']."</td>
			<td>Address--".$rowReg['Address']."</td></tr></table>";
		}
	}
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.