Enjoy an ad free experience by logging in. Not a member yet?
Register .
01-09-2006, 05:27 PM
PM User |
#1
New Coder
Join Date: Jan 2005
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Display sql results in html table
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 Code:
<?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"> </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"> </p>
<p align="left"><br>
</p>
<p align="left"> </p>
<p align="left"> </p>
<p> </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>
01-09-2006, 07:06 PM
PM User |
#2
New Coder
Join Date: Jan 2006
Location: Oslo, Norway
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by croix
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.
__________________
Drømmejenta: Kristen jente som progger Python!
01-10-2006, 01:48 PM
PM User |
#3
Senior Coder
Join Date: Nov 2002
Location: North-East, UK
Posts: 1,265
Thanks: 0
Thanked 0 Times in 0 Posts
There are different ways. You could put your results into a variable or you could move the code to output within the table
PHP Code:
<!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"> </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"> </p>
<p align="left"><br>
</p>
<p align="left"> </p>
<p align="left"> </p>
<p> </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>
01-10-2006, 05:39 PM
PM User |
#4
Senior Coder
Join Date: Apr 2005
Location: Colorado, United States
Posts: 1,208
Thanks: 0
Thanked 0 Times in 0 Posts
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.
__________________
"$question = ( to() ) ? be() : ~be();"
Jump To Top of Thread
Thread Tools
Rate This Thread
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
All times are GMT +1. The time now is 03:00 AM .
Advertisement
Log in to turn off these ads.