Jump to content

Gethering info from database


skoobi

Recommended Posts

Hi im having problems with displaying the informtaion from the database onto a page... Whats happening is that its displaying multiple lines i.e. if i make an order for example by 'chris' then that updates into the database.. but if i do another order for instance 'Ted'; When i check the orders it comes up with the chris one as a duplicate with ted's order...

But in the database itself all is ok so it must be the coding ive done...

 

Heres what ive got so far... (Also the tutorial on the php search was amazingly usefull... Thank you)

 

<?php
include ('../includes/db.php');
include('search.php');
?>       
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Orders</title>
</head>


<body>

<a href="orders.php">Refresh</a> || <a href="admin.php">Back to Admin</a> <br/><br/>

<form method="GET" action="<?php echo $_SERVER['PHP_SELF'];?>" name="searchForm"> 
<input type="text" name="search" value="<?php echo isset($searchTerms)?htmlspecialchars($searchTerms):''; ?>" />
<input type="submit" name="submit" value="Search!" /> ||
First Name: <input type="checkbox" name="firstname" value="on" <?php echo isset($_GET['firstname'])?"checked":''; ?> /> ||
Last Name: <input type="checkbox" name="lastname" value="on" <?php echo isset($_GET['lastname'])?"checked":''; ?> /> ||
House Name: <input type="checkbox" name="address1" value="on" <?php echo isset($_GET['address1'])?"checked":''; ?> /> || 
Post Code: <input type="checkbox" name="zip" value="on" <?php echo isset($_GET['zip'])?"checked":''; ?> />
</form>
<br />
<?php echo (count($error) > 0)?"The following had errors:<br /><span id=\"error\">" . implode("<br />", $error) . "</span><br /><br />":""; ?>
<?php echo (count($results) > 0)?"Your search for '{$searchTerms}' returned:<br /><br />" . implode("", $results):""; ?>
<?php

$result = mysql_query("SELECT * FROM customers,order_detail ORDER BY orderid DESC");

echo "<table border='1'>
<tr>
<th>Order Number</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Address 1</th>
<th>Address 2</th>
<th>City</th>
<th>State</th>
<th>Post Code</th>
<th>Phone</th>
<th>Payment</th>
<th>Price</th>
<th>Payed</th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td>" . $row['orderid'] . "</td>";
  echo "<td>" . $row['firstname'] . "</td>";
  echo "<td>" . $row['lastname'] . "</td>";
  echo "<td>" . $row['address1'] . "</td>";
  echo "<td>" . $row['address2'] . "</td>";
  echo "<td>" . $row['city'] . "</td>";
  echo "<td>" . $row['state'] . "</td>";
  echo "<td>" . $row['zip'] . "</td>";
  echo "<td>" . $row['phone'] . "</td>";
  echo "<td>" . $row['payment'] . "</td>";
  echo "<td>£" . $row['price'] . "</td>";
  echo "<td>" . $row['payed'] . "</td>";
  echo "</tr>";
  }
echo "</table>";
mysql_close();
?>
</body>
</html>

 

Any advise would be greatful

 

Thanks

Chris

Link to comment
https://forums.phpfreaks.com/topic/179198-gethering-info-from-database/
Share on other sites

try

 

$result = mysql_query("SELECT * FROM customers,order_detail GROUP BY orderid ");

 

actually i cant delete this but are you drawing from 2 tables?

 

SELECT * FROM customers,order_detail

 

If so your query is messed up

 

there is a freebie called toad that has a query builder that makes complex statements in php for multiple tables

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.