array empty


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

Hiya peeps,

Ok here is the codes.

Did you know?Explore Trending and Topic pages for more stories like this.
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: &pound;'.$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 &pound;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 Like 24 Dislike
Previous forums Next forums
Other forums

Help with syntax
Hi all!

The $bridge variable is not getting passed while it is contained in the line below:

Insert data in Mysql and move to another page
I'm stuck with this simple problem. I need to insert data in Mysql and then hit submit and move to a

License Issue - service type user
Hi,

I would like to understand the following issue regarding sap license.
I wish to

Open link with largest int string first
I have the following links i would like to open either all at once or one-by-one. How would i procee

how to remove in php string display
My code is

$message="We're looking at developing our website.";

$body= "

Load Animated Image while cache is serve
I have a page that loads up using cache and took about 1 to 2 minutes before it loads to the page. <

Count
Getting the same count everytime

Code:
$visitquery = mysql_query("SELECT COUNT(*) FR

PHP page is blank
Hi Everyone,

I have a site in which I am able to open the first PHP webpage in my browser but

ClientScript.RegisterClientScriptBlock Issue
This is what I haveview plaincopy to clipboardprint?Protected Sub posrback_Click(ByVal sender As Obj

Date help - fetch dates for Mondays between xxx and yyy?
Does anyone know the best way to do this? I have two dates, say:

2010-01-26 and 2010-05-30

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