I have almost did the displaying of values.But i am getting an extra td I hope the complete code is right. Can anyone see it once.
php
<?php
session_start();
$link = mysqli_connect('localhost','root','','hoteldetails');
$sno[]="";
$roomImage[]="";
$roomNo[] = "";
$hotelName[]="";
$roomPrice[]="";
$loc[]="";
if(isset($_POST['sub']))
{
// mysqli_s(elect_db($link, "hotels");
$location=$_POST['searchVal'];
$sql = "select * from roomdetails where Location = '$location'";
$sqldata= mysqli_query($link ,$sql);
while($row = mysqli_fetch_array($sqldata)){
$sno[]=$row['S.No'];
$roomImage[] = $row['RoomImage'];
$roomNo[] = $row['RoomNo'];
$hotelName[] = $row['HotelName'];
$roomPrice[] = $row['RoomPrice'];
$loc[] = $row['Location'];
}
//two arrays to display ,$combine = array_combine($one,$two);
}
?>
html
<?php
echo "<table border='1'>";
echo "<tr><th>Hotel</th><th>Location</th></tr>";
foreach($sno as $id => $key):
echo "<tr>";
echo "<td>";?><img src="<?php echo $roomImage[$id];?>" height="100" width="100"><?php echo "</td>";
echo "<td>".$roomNo[$id]."</td>";
echo "<td>".$hotelName[$id]."</td>";
echo "<td>".$roomPrice[$id]."</td>";
echo "<td>".$loc[$id]."</td>";
echo "</tr>";
endforeach;
echo "</table>";
//echo $html;
?>
Is there anything wrong in it . Please is this process is right to display the values from mysql into html.