HTML/Javascript

SES by business degree online promotion team.

Philippine Airlines International Flight schedules

Philippine Airlines International Flight schedules
Philippine Airlines International Flight schedules

Search This Blog

Monday, September 13, 2010

php sample display data from mysql database using html table to your php file

code to paste:

<html>
<body>
<table border="1" align="center">

<form action="query.php" method="post">
<tr>
<td>Marina Number:</td>
<td><input type="text" name="marinanumber" maxlength="7" /></td>
</tr>

<tr>
<td><input type="submit" value="search data"/></td>
<td>&nbsp;</td>
</tr>

</form>

</table>
<br>
<br>
<br>


<?php

$con = mysql_connect("localhost","root","mypassword");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("personalinfo", $con);

$search=$_POST['idnumber'];


$result = mysql_query("SELECT * FROM marinax where idnumber='$search'");
$count=mysql_num_rows($result);

if($count==1)
{
while($row = mysql_fetch_array($result))
{
echo "<p align='center'>Record found for ID Number:" . $row['idnumber'] . "</p>";
echo "<table border='1' align='center'>";
echo "<tr>";
echo "<td>Name:</td>";
echo "<td>" . $row['name'] . "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Adress:</td>";
echo "<td>" . $row['address'] . "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>City:</td>";
echo "<td>" . $row['city'] . "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>State:</td>";
echo "<td>" . $row['state'] . "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>ZipCode</td>";
echo "<td>" . $row['zipcode'] . "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Warranty:</td>";
echo "<td>" . $row['religion'] . "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Non-warranty</td>";
echo "<td>" . $row['address'] . "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Tech Number:</td>";
echo "<td>" . $row['petsname'] . "</td>";
echo "</tr>";
echo "</table>";
}

}
else
{
echo "record not found";
}


mysql_close($con)
?>

No comments:

Post a Comment