...

View Full Version : Display sql results in html table



croix
01-09-2006, 06:27 PM
I know how to display my results in a plain html table, but how can I display the results in my existing webpage?

see what I mean:
http://www.sliquid.com/protected/admin.php
user - admin
pass - temppass2

Then click on Search / Edit Records under Customers.

search for "dallas" or "texas" to see my results.


How can I get these results to display within my html?

heres my code right now:


<?php
include("dbconnection.php");

if (isset($_POST['Submit'])) {
$search = $_POST['search'];
$date = $_POST['date'];
$query = "SELECT firstname,lastname,city,state,email FROM customers WHERE firstname = '$search' OR lastname = '$search' OR city = '$search' OR state = '$search' OR email = '$search' AND date >= '$date' ORDER BY date asc";

$result = odbc_exec($cnx, $query);

while ($row = odbc_fetch_array($result)) {

/*
echo "<p>SQL: $query</p>";
if ($result === false)
echo "<p>odbc_exec returned false, msg: " . odbc_errormsg() . "</p>";
else echo "<p>odbc_exec returned " . odbc_num_rows($result) . " rows.</p>";
*/

echo "
<div id=\"container\">
<center>
<TABLE CELLPADDING=0 CELLSPACING=0 width=\"60%\"><tr align=center bgcolor=lightsteelblue>
<th><font face=\"Tahoma\" size=\"1\"><b>First Name:</b></font></th>
<th><font face=\"Tahoma\" size=\"1\">Last Name:</font></th>
<th><font face=\"Tahoma\" size=\"1\">City:</font></th>
<th><font face=\"Tahoma\" size=\"1\">State:</font></th>
<th><font face=\"Tahoma\" size=\"1\">Email:</font></th>
</tr><br>
<tr align=center bgcolor=gainsboro>
<td><font face=\"Tahoma\" size=\"1\">$row[firstname]</font></td>
<td><font face=\"Tahoma\" size=\"1\">$row[lastname]</font></td>
<td><font face=\"Tahoma\" size=\"1\">$row[city]</font></td>
<td><font face=\"Tahoma\" size=\"1\">$row[state]</font></td>
<td><font face=\"Tahoma\" size=\"1\">$row[email]</font></td>
</tr>
</table>
</center>
</div>";

}

}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sliquid Personal Lubricant - Glycerine free intimate lubrication </title>
<meta name="description" content="Admin Only - Sliquid personal lubricants. ">
<meta name="keywords" content="articles, information, lube, sliquid, personal, feminine, women, lubricant, lubrication, lasting, intimate, massage, intercourse, glycerin, glycerine, sugar, water,
based, latex, friendly, sex">
<meta NAME="REVISIT-AFTER" CONTENT="14 days">
<meta name="author" content="Sliquid, LLC - 5706 Goodwin Ave, Dallas, TX 75206">
<meta NAME="ROBOTS" CONTENT="ALL">
<meta NAME="DISTRIBUTION" CONTENT="GLOBAL">
<link rel="stylesheet" href="" type="text/css" media="all" />
<meta http-equiv="dialect" content="us">
<meta http-equiv="language" content="english">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<meta name="copyright" content="Copyright (c)1994-2005 SLIQUID. All rights reserved." />
<link rel="stylesheet" type="text/css" href="style2.css" />
<style type="text/css">
<!--
.style1 {
font-size: 16px;
font-weight: bold;
}
.style2 {font-size: 12px}

-->
</style>
</head>
<body><?php require_once("adminOnly.php");?>
<div id="container">




<div id="header"></div>

<div id="leftcol2">
<ul class="menu">
<li class="head"><img src="images/products.jpg" alt="Products" width="109" height="25"></li>
<li><a href="http://www.sliquid.com/h2o.htm"> H2O </a></li>
<li><a href="http://www.sliquid.com/silver.htm">Silver</a></li>
<li><a href="http://www.sliquid.com/silk.htm">Silk </a></li>
<li><a href="http://www.sliquid.com/sizzle.htm">Sizzle </a></li>
<li><a href="http://www.sliquid.com/swirl.htm">Swirl</a></li>
<li><a href="http://www.sliquid.com/stay.htm">Stay</a></li>
<li><a href="http://www.sliquid.com/stim.htm">Stim</a></li>
<li><a href="http://www.sliquid.com/splash.htm">Splash</a></li>
<li><a href="http://www.sliquid.com/scents.htm">Scents</a></li>
<li><a href="http://www.sliquid.com/solo.htm">Solo</a></li>

<img src="images/clothing.jpg" alt="Clothing" width="109" height="25">
<li><a href="http://www.sliquid.com/tshirts.htm">T Shirts</a></li>
<li><a href="http://www.sliquid.com/babydoll.htm">Baby Doll T's </a></li>
<li><a href="http://www.sliquid.com/tanktops.htm">Tank Tops</a></li>
<li><a href="http://www.sliquid.com/hats.htm">Trucker Hats </a></li>
<li><a href="http://www.sliquid.com/stickers.htm">Stickers</a><img src="images/home.jpg" alt="Home" width="109" height="25" border="0" usemap="#Map">
<map name="Map">
<area shape="rect" coords="1,2,105,21" href="http://www.sliquid.com/index.htm" alt="Home">
</map>
</li>
</ul>
</div>
<div id="leftcol">
<div align="center">
<div id="table1">
<h1><span class="style1">Search for Customer Records </span><br>
<span class="style2">Please to remember to logout when you are done. </span><br>
</h1>
</div><div id="table1">
<form name="form1" method="post" action="">
<p align="left">&nbsp;</p>
<table width="480" border="0">
<tr>
<td width="227"><p align="left">Search for Name, City, State:</p> </td>
<td width="218"><div align="left">Created since: </div></td>
</tr>
<tr>
<td><div align="left">
<input name="search" type="text" id="search2" size="25" value="*">
</div></td>
<td><div align="left">
<input name="date" type="text" id="date3" value="01/01/2005" size="13">
</div></td>
</tr>
<tr>
<td height="45"><div align="left">
<input type="submit" name="Submit" value="Submit">
</div></td>
<td><div align="left"></div></td>
</tr>
</table>
<p align="left"><br>
</p>
<p align="left">&nbsp;</p>
<p align="left"><br>
</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp; </p>
<p>&nbsp; </p>
</form>
</div>
<br>
</div>
</div>


<div id="rightcol">
<ul class="menu">
<li class="head"><img src="images/dealers.jpg" alt="Dealers" width="109" height="25"></li>
<li><a href="http://www.sliquid.com/webdealers.htm">Web Dealers </a></li>
<li><a href="http://www.sliquid.com/retailers.htm">Retail Locations </a></li>
<li><a href="http://www.sliquid.com/homeparties.htm">Home Parties </a></li>
<li><a href="http://www.sliquid.com/distributors.htm">Distributors </a></li>
</ul>
<img src="images/news.jpg" alt="News" width="109" height="25">
<ul class="menu">
<li><a href="http://www.sliquid.com/tradeshows.htm">Trade Shows </a></li>
<li><a href="http://www.sliquid.com/media.htm">Media / Press</a></li>
<li><a href="http://www.sliquid.com/articles.htm">Useful Articles</a></li>

<img src="images/feedback.jpg" alt="Feedback" width="109" height="25"><li><a href="http://www.sliquid.com/reviews.htm"> Reviews </a></li><li><a href="http://www.sliquid.com/testimonials.htm"> Testimonials </a></li>
<li><a href="http://www.sliquid.com/guestbook.htm">Guests</a></li>
<li><span class="head"><img src="images/contact.jpg" alt="Contact" width="109" height="25"></span></li>
<li><a href="http://www.sliquid.com/general.htm">General</a></li>
<li><a href="http://www.sliquid.com/email.htm">
Email / Links</a></li>
<li><a href="http://www.sliquid.com/livehelp.htm">
Live Help </a></li>
<li><a href="http://www.sliquid.com/become.php">Sell Sliquid!</a><img src="images/home.jpg" alt="Home" width="109" height="25" border="0" usemap="#Map2">
<map name="Map2">
<area shape="rect" coords="3,3,105,22" href="http://www.sliquid.com/index.htm" alt="Home">
</map>
</li>
</ul>
</div>
<div id="footer"> copyright Sliquid LLC, 2002</div>
</div>

</body>
</html>

jskaar
01-09-2006, 08:06 PM
How can I get these results to display within my html?
Cold you try to explain what you want to do? You'll have to excuse my english, but I cant figure out what your problem is/what you want. :)

degsy
01-10-2006, 02:48 PM
There are different ways. You could put your results into a variable or you could move the code to output within the table




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sliquid Personal Lubricant - Glycerine free intimate lubrication </title>
<meta name="description" content="Admin Only - Sliquid personal lubricants. ">
<meta name="keywords" content="articles, information, lube, sliquid, personal, feminine, women, lubricant, lubrication, lasting, intimate, massage, intercourse, glycerin, glycerine, sugar, water,
based, latex, friendly, sex">
<meta NAME="REVISIT-AFTER" CONTENT="14 days">
<meta name="author" content="Sliquid, LLC - 5706 Goodwin Ave, Dallas, TX 75206">
<meta NAME="ROBOTS" CONTENT="ALL">
<meta NAME="DISTRIBUTION" CONTENT="GLOBAL">
<link rel="stylesheet" href="" type="text/css" media="all" />
<meta http-equiv="dialect" content="us">
<meta http-equiv="language" content="english">
<meta http-equiv="imagetoolbar" content="no">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta name="MSSmartTagsPreventParsing" content="TRUE" />
<meta name="copyright" content="Copyright (c)1994-2005 SLIQUID. All rights reserved." />
<link rel="stylesheet" type="text/css" href="style2.css" />
<style type="text/css">
<!--
.style1 {
font-size: 16px;
font-weight: bold;
}
.style2 {font-size: 12px}

-->
</style>
</head>
<body><?php require_once("adminOnly.php");?>
<div id="container">




<div id="header"></div>

<div id="leftcol2">
<ul class="menu">
<li class="head"><img src="images/products.jpg" alt="Products" width="109" height="25"></li>
<li><a href="http://www.sliquid.com/h2o.htm"> H2O </a></li>
<li><a href="http://www.sliquid.com/silver.htm">Silver</a></li>
<li><a href="http://www.sliquid.com/silk.htm">Silk </a></li>
<li><a href="http://www.sliquid.com/sizzle.htm">Sizzle </a></li>
<li><a href="http://www.sliquid.com/swirl.htm">Swirl</a></li>
<li><a href="http://www.sliquid.com/stay.htm">Stay</a></li>
<li><a href="http://www.sliquid.com/stim.htm">Stim</a></li>
<li><a href="http://www.sliquid.com/splash.htm">Splash</a></li>
<li><a href="http://www.sliquid.com/scents.htm">Scents</a></li>
<li><a href="http://www.sliquid.com/solo.htm">Solo</a></li>

<img src="images/clothing.jpg" alt="Clothing" width="109" height="25">
<li><a href="http://www.sliquid.com/tshirts.htm">T Shirts</a></li>
<li><a href="http://www.sliquid.com/babydoll.htm">Baby Doll T's </a></li>
<li><a href="http://www.sliquid.com/tanktops.htm">Tank Tops</a></li>
<li><a href="http://www.sliquid.com/hats.htm">Trucker Hats </a></li>
<li><a href="http://www.sliquid.com/stickers.htm">Stickers</a><img src="images/home.jpg" alt="Home" width="109" height="25" border="0" usemap="#Map">
<map name="Map">
<area shape="rect" coords="1,2,105,21" href="http://www.sliquid.com/index.htm" alt="Home">
</map>
</li>
</ul>
</div>
<div id="leftcol">
<div align="center">
<div id="table1">
<h1><span class="style1">Search for Customer Records </span><br>
<span class="style2">Please to remember to logout when you are done. </span><br>
</h1>
</div>
<?php
// Show If
include("dbconnection.php");

if (isset($_POST['Submit'])) {
$search = $_POST['search'];
$date = $_POST['date'];
$query = "SELECT firstname,lastname,city,state,email FROM customers WHERE firstname = '$search' OR lastname = '$search' OR city = '$search' OR state = '$search' OR email = '$search' AND date >= '$date' ORDER BY date asc";

$result = odbc_exec($cnx, $query);

while ($row = odbc_fetch_array($result)) {

/*
echo "<p>SQL: $query</p>";
if ($result === false)
echo "<p>odbc_exec returned false, msg: " . odbc_errormsg() . "</p>";
else echo "<p>odbc_exec returned " . odbc_num_rows($result) . " rows.</p>";
*/

echo "
<div id=\"container\">
<center>
<TABLE CELLPADDING=0 CELLSPACING=0 width=\"60%\"><tr align=center bgcolor=lightsteelblue>
<th><font face=\"Tahoma\" size=\"1\"><b>First Name:</b></font></th>
<th><font face=\"Tahoma\" size=\"1\">Last Name:</font></th>
<th><font face=\"Tahoma\" size=\"1\">City:</font></th>
<th><font face=\"Tahoma\" size=\"1\">State:</font></th>
<th><font face=\"Tahoma\" size=\"1\">Email:</font></th>
</tr><br>
<tr align=center bgcolor=gainsboro>
<td><font face=\"Tahoma\" size=\"1\">$row[firstname]</font></td>
<td><font face=\"Tahoma\" size=\"1\">$row[lastname]</font></td>
<td><font face=\"Tahoma\" size=\"1\">$row[city]</font></td>
<td><font face=\"Tahoma\" size=\"1\">$row[state]</font></td>
<td><font face=\"Tahoma\" size=\"1\">$row[email]</font></td>
</tr>
</table>
</center>
</div>";
}
}
// Else Show

else {
?>
<div id="table1">
<form name="form1" method="post" action="">
<p align="left">&nbsp;</p>
<table width="480" border="0">
<tr>
<td width="227"><p align="left">Search for Name, City, State:</p> </td>
<td width="218"><div align="left">Created since: </div></td>
</tr>
<tr>
<td><div align="left">
<input name="search" type="text" id="search2" size="25" value="*">
</div></td>
<td><div align="left">
<input name="date" type="text" id="date3" value="01/01/2005" size="13">
</div></td>
</tr>
<tr>
<td height="45"><div align="left">
<input type="submit" name="Submit" value="Submit">
</div></td>
<td><div align="left"></div></td>
</tr>
</table>
<p align="left"><br>
</p>
<p align="left">&nbsp;</p>
<p align="left"><br>
</p>
<p align="left">&nbsp;</p>
<p align="left">&nbsp; </p>
<p>&nbsp; </p>
</form>
</div>
<?php
// End If
}
?>
<br>
</div>
</div>


<div id="rightcol">
<ul class="menu">
<li class="head"><img src="images/dealers.jpg" alt="Dealers" width="109" height="25"></li>
<li><a href="http://www.sliquid.com/webdealers.htm">Web Dealers </a></li>
<li><a href="http://www.sliquid.com/retailers.htm">Retail Locations </a></li>
<li><a href="http://www.sliquid.com/homeparties.htm">Home Parties </a></li>
<li><a href="http://www.sliquid.com/distributors.htm">Distributors </a></li>
</ul>
<img src="images/news.jpg" alt="News" width="109" height="25">
<ul class="menu">
<li><a href="http://www.sliquid.com/tradeshows.htm">Trade Shows </a></li>
<li><a href="http://www.sliquid.com/media.htm">Media / Press</a></li>
<li><a href="http://www.sliquid.com/articles.htm">Useful Articles</a></li>

<img src="images/feedback.jpg" alt="Feedback" width="109" height="25"><li><a href="http://www.sliquid.com/reviews.htm"> Reviews </a></li><li><a href="http://www.sliquid.com/testimonials.htm"> Testimonials </a></li>
<li><a href="http://www.sliquid.com/guestbook.htm">Guests</a></li>
<li><span class="head"><img src="images/contact.jpg" alt="Contact" width="109" height="25"></span></li>
<li><a href="http://www.sliquid.com/general.htm">General</a></li>
<li><a href="http://www.sliquid.com/email.htm">
Email / Links</a></li>
<li><a href="http://www.sliquid.com/livehelp.htm">
Live Help </a></li>
<li><a href="http://www.sliquid.com/become.php">Sell Sliquid!</a><img src="images/home.jpg" alt="Home" width="109" height="25" border="0" usemap="#Map2">
<map name="Map2">
<area shape="rect" coords="3,3,105,22" href="http://www.sliquid.com/index.htm" alt="Home">
</map>
</li>
</ul>
</div>
<div id="footer"> copyright Sliquid LLC, 2002</div>
</div>

</body>
</html>

Velox Letum
01-10-2006, 06:39 PM
Personally I'd recommend executing all the code first and feeding that into a variable, then echoing out the variable in the right place...less messy and far easier to work with and make changes.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum