Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Display SQL results in existing HTML
Old 01-09-2006, 12:36 PM Display SQL results in existing HTML
croix's Avatar
Skilled Talker

Posts: 87
Name: Colin Roy
Location: Dallas, TX
Trades: 0
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">&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>
__________________

Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
croix is offline
Reply With Quote
View Public Profile Visit croix's homepage!
 
 
Register now for full access!
Old 01-09-2006, 04:19 PM
Extreme Talker

Posts: 219
Location: UK, East Anglia
Trades: 0
You need to create a header and footer files with the html that will appear above the output in the header and the html that will appear under it in the footer file.

Then you include the files in your php file.

PHP Code:
<?php
include("dbconnection.php");
include (
"header.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>"


}
include (
"footer.php");
timsquash5 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Display SQL results in existing HTML
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15727 seconds with 12 queries