Jump to content

I want to display just top 5 rows from the database


ankit.pandeyc012

Recommended Posts

<?php
require_once('upper.php');

require_once('database.php');
if(isset($_COOKIE['LoginIdCookie']))
{
echo '<h4>Welcome '.$_COOKIE['LoginIdCookie'].'</h4>';
}
else{ echo '<h4>Events</h4>';}
$result=mysqli_query($dbc,"select * from events") or die('Not Connected');
echo "<html>
	<body>";
  echo "<form method='post' action='EventParticipator.php'>"; 
  echo	"<u><h4>Please tick events in which you want to participate</h4></u>";
  /*echo "<table cellspacing='0' cellpadding='15'>
  		<th><b>Event Title:</b></th>
  		<th ><b>Event City:</b></th>
	<th><b>Content:</b></th>
	<th><b>Images:</b></th>
	<th><b>Event Date:</b></th>";*/

//while($row=mysqli_fetch_array($result))
$row=mysqli_fetch_array($result);
for($i=0;$i<5;$i++)
{
$Title=$row['Title'];
$City=$row['City'];
$Content=$row['Content'];
//$Photo=$row['Photo'];
$Date=$row['Date'];
$EventId=$row['EventId'];
$Photo=$row['Photo'];
//echo $Photo;

echo "<tr><td><img src='$Photo' width='120' height='90'/></td><td>$City</td><td>,</td><td>$Date</td><td>:</td><td>$Title</td></tr>
	<tr><td>$Content</td></tr>
	<tr><td><a href='#'>Know more</a></td><td>/</td><td><a href='#'>Click here to participate</a></td></tr>"; 
}
//echo "<tr><td><input type='submit' name='submit' value='Participate'</td>";
if(isset($_COOKIE['LoginIdCookie']))
{
echo "<td><a href='log_out.php'>Log out</a></td>";
echo "<td><a href='EditActivity.php'>Edit Your Activities</a></td></tr>";
}
echo "</table></form></body></html>";
require_once('lower.php');
?>

 

 

 

 

Hi friends ..........

I write above code to display top 5 rows from the database but it not works properly. It displays first row 5 times which is undesireable.

Anyone plz help?????????????????

Thx in advance..................

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.