Sql and php order list script problems


Posted on 16th Feb 2014 07:03 pm by admin

Hi im having a few problems with trying to get the coding right on a orders list ive done (or trying to do) for a custom shopping cart im making... For some reason it comes up with all the orders in stead of 1. i.e. If there i start from scratch ill have order number 1 which will have the order in but if i create another order it displays order number 2 twice with both the customers details on...

Heres the code:
Code: <?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 INNER JOIN 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>Total</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['total'] . "</td>";
echo "<td>" . $row['payed'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysql_close();
?>
</body>
</html>
Im completely stuck on this as im no php or mysql gurru...
so any help or info would be greatfull..

No comments posted yet

Your Answer:

Login to answer
234 Like 14 Dislike
Previous forums Next forums
Other forums

Install page
How do I make it so when a user submits information on the Install page, it'll right it into the cor

want to add a break after a certain amount of characters
i was wondering how to add a break in a blog post after a certain amount of characters... any idea o

Need to write a cookie with a url var
Not sure if its possible, but I need to write a cookie with a url.

So this would write 2232 a

Coding question?
Hey guys, I have a quick question. If I want to make a way for people to pay for health in my game,

Form Help
Here is the form:

Line number On/Off | Expand/Contract<? include("../include/sess

Multiple server callbacks (NOT POSTBACKS)
Hello, I have 2 different javascript client side functions that are on timers. When the timers elap

Must be a string? Huh, what? HELP?
with the following script, I get
Fatal error: Property name must be a string in /home/content/e/

Time-based image rotation script
I'm trying to write a PHP script that rotates an image based on what time of day it is. I want the

pop3 and fsockopen
So I am able to connect to the pop3 server, log in, and check how many messages there are. I am hav

If a form submits back to same page do you need to use $get
IM trying to pass page number and year that was selected back to the same page.

i have this c

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash