array empty
Posted on
16th Feb 2014 07:03 pm by
admin
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
No comments posted yet
Your Answer:
Login to answer
113
24
Other forums
help with calculations on a flat text file
hello,
I have this code below that is attached to a flat file like this:
Email:LastName:FirstN
ereg_replace in Wordpress
Heya - so I'm working on this site: http://world-of-smiles.theportlandco.com/new-patients
The
Grabbing Values From an Array for Posting
I have a grid array that I am using with a form that when it hits the currently named test.php it lo
How do I use ValidatorCallout extender in Login control?
Hi,I'd like to customize the look and feel of the login control a little bit. One thing I'd love to
Code error with Index.php
Error: Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/runevid/public_
How to submit a form to the same page?
I have a table containing information about books in my library and this table has the following col
Saas with SAP R/3
hi experts,
Is SaaS offer available in SAP? for SAP R/3? from where i can get the info a
please fix the error
What is the error in the below code ???
Line number On/Off | Expand/Contract <?php
phpmailer class & pop.gmail.com?
Code: <?php
$mail->IsSMTP();
$mail->Host = "pop.gmail.com";
How to display random record from table?
I have the following code:
Code: <?php
$display_block .= "<input type=