SusanH
06-06-2010, 02:56 PM
If you want to display the records in a table in vertical format. (eg)\
John
Doe
sales
-------
Jane
Doe
marketing
---------
Bill
Jacobs
finance
---------
Kate
Kite
service
------
<html>
<head>
<title>Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<h1>Search Results</h1>
<?php
$database="dbname";
mysql_connect ("localhost", "username", "password");
@mysql_select_db($database) or die( "Unable to select database");
$query = "select * from tablename";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p>Number matches found: ".$num_results."</p>";
echo "<hr>";
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<p><strong># ";
echo stripslashes($row["contact_id"]);
echo "<p><strong>Name: ";
echo stripslashes($row["first_name"]);
echo "<p><strong>Category: ";
echo stripslashes($row["category"]);
echo "<p><strong>Comment: ";
echo stripslashes($row["comments"]);
echo "<hr>";
echo "</p>";
}
?>
</body>
</html>
You only have to modify these lines with your information:
$database="dbname";
mysql_connect ("localhost", "username", "password");
$query = "select * from tablename";
Have Fun:)
John
Doe
sales
-------
Jane
Doe
marketing
---------
Bill
Jacobs
finance
---------
Kate
Kite
service
------
<html>
<head>
<title>Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
<body>
<h1>Search Results</h1>
<?php
$database="dbname";
mysql_connect ("localhost", "username", "password");
@mysql_select_db($database) or die( "Unable to select database");
$query = "select * from tablename";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
echo "<p>Number matches found: ".$num_results."</p>";
echo "<hr>";
for ($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo "<p><strong># ";
echo stripslashes($row["contact_id"]);
echo "<p><strong>Name: ";
echo stripslashes($row["first_name"]);
echo "<p><strong>Category: ";
echo stripslashes($row["category"]);
echo "<p><strong>Comment: ";
echo stripslashes($row["comments"]);
echo "<hr>";
echo "</p>";
}
?>
</body>
</html>
You only have to modify these lines with your information:
$database="dbname";
mysql_connect ("localhost", "username", "password");
$query = "select * from tablename";
Have Fun:)