Hiya peeps,
Ok here is the codes.
order.php
Code:
<?php
if(!isset($_POST) OR empty($_POST)) {
echo '<h1 align="center">There was an error with your order!</h1><h2 align="center"><a href="index.php">Start again</a></h2>';
} else {
$tesco = new Tesco();
foreach($_POST as $key => $value) {
$tesco->getPrice($value, $key);
}
echo '<h1><u>You ordered:</u></h1>';
echo '<h2>'.$cnt[$row['id']].' x '.$row['name'].'</h2>';
echo '<h1><u>Results</u></h1>';
echo '<h2>Cheapest at: ' . $store . '</h2>';
echo '<h2>Amount: £'.$total.'</h2>';
if($total > 50) {
echo '<a href="" onclick="" class="buttonn">Deliver it!</a>';
} elseif ($total < 50) {
echo '<a href="" onclick="" class="buttonn">Deliver it for £9.99!</a>';
}
}
?>
tesco.php
Code: <?php
class Tesco {
private $quantity;
private $productid;
function getPrice($quantity, $productid, $storeid = '1') {
$this->quantity = mysql_real_escape_string(trim(addslashes(strip_tags(is_numeric($quantity)))));
$this->productid = mysql_real_escape_string(trim(addslashes(strip_tags(is_numeric($productid)))));
$this->storeid = mysql_real_escape_string(trim(addslashes(strip_tags(is_numeric($storeid)))));
$this->query = "SELECT * FROM `products` WHERE id = '$this->productid' AND store = '$this->storeid'";
$this->result = mysql_query($this->query) or trigger_error('Query failed: ' . mysql_error(), E_USER_ERROR);
while($this->price = mysql_fetch_object($this->result)):
if($this->quantity > 1):
$this->total[] = $this->price->price*$this->quantity;
elseif ($this->quantity = 1):
$this->total[] = $this->price->price;
endif;
endwhile;
print_r($this->total);
}
}
?>
As you can see in the tesco.php file i have a print_r() this is what is being returned..
Array ( => ) Array ( => [1] => )
(i have inputed two product id's).
Many thanks
Need help to modify php ELSE code
I'm trying to find a way to have the php code display a message if there is no inventory listed in the box, I just want it to say something like "User has no inventory listed" You can see
Chat Box in PHP
I was thinking in doing a Chat Box in PHP. For that I would use a form with two fields, Nick and Message, then I would store the data in a DB and show them.I have already made the code for this. In
Session is not saving
I am not trying to do anything too fancy, I am just trying to get some $_SESSION data to save and use it on the next page, but so far no luck. Its saving some data to $_SESSION['name'] and then
Strange array issue, never happened before.
mysql_fetch_array returns 1 array per call. Generally that's why it is inserted into a while statement. I generally loop through them in a while statement and put them all in a master array so I
Refining of search Criteria
Dear FriendsI need a help, I have a search page which of cars related, which has different search criteria e.g. maker, model, color, displacement etc. when i give any search criteria and click the
defining website tags
Hi,What would be the best way to define tags for my site, such as website title, url etc.Should I just use somethng like:$website_name = "name";or should I use arrays?Thanks
Save User Inputs while javascript reloading!
hi..i have written a PHP code in which i reload the page when user selects a value in dropdown...Code: function reload(form){var
PHP Session Issue
I'm having an issue with one section on my website dealing with sessions. Now I know that myself and two other individuals can get it to work without any issues on IE, FF, or other browsers, however,
Change Sort Order to Display Newest File First
Hi Guys,I have a page that sorts the contents (PDFs) of a directory and displays them on the webpage chronologically from the oldest (at top) to the newest (at bottom).I'd like to reverse this display
I think i'm using the syntax incorrectly
Hi Everyone!I'm new to this forum and a newbie with PHP - I'm glad I found this site - I hope to learn a lot! For my first and hopefully one of few questions, lol..I told my boss i'd help him out