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
Impact of movement type 412 E on MAP
Hi
Selecting an "empty" date formated field
How do you select an "empty" date field? I've tried the few ways I can think.
Showing selected item at top of list
Hi,I've got a list of names which i am fetching from database like this: $qry = db_query("SELECT * FROM names"); $i=1; //prepair list $html .=
puting for loop in 1 value
hi ,how do i put this code in 1 value:Code: <?phpfor ($i=1; $i<=5; $i++) { echo $i ; }?>the output will be: 12345how do i put the result in one value ,some thing like :if the
Get dump of MySQL DB from Live Site
I'm after an easy, but secure way of generating and importing a MySQL dump from a remote server. The way I want to achieve this is as follows: 1) I will have a page on my localhost server with a form
Help: calling function
Hi,Is it possible to call a php function on page close?If yes, could you explain how and where to call?any example code will be appreciated.Thanks
filesize() returns 0
I have a socket program that runs in an infinite loop, listening for connections, in this socket I have a method, that is supposed to open a file and write to the file, but I am having issues. Each
PHP Thumbnail Creation
Ok so i use this function to create thumbnails:Code: [Select]function createthumb($name,$filename,$new_w,$new_h){ $system=explode('.',$name); $src_img=imagecreatefrompng($name);
How to clone an SAP ECC using bacup tape on z/os?
We want to clone our production to a different SID using backup tape.
Looking for help reading a .txt or .ini file and outputting the info.
I have a file called Info.ini and It has the following info:Code: [General]Online=0I would like it to be in a php file as just 0 if possible. Also how would I do this from php file to php file and let