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

how do i make a string??
hey guys,
can someone please tell me how to put data from the glob function into a string

Post PHP form to non-existing page
The company that I work for host their PHP code on IIS on a Windows server, no Apache, so no mod_rew

A rank users order by points
I want to make an insert from table 'rank' , with number (rank) from the cod blow, to fild users.ran

close site for maintenance
i get a tutorial, saying the following code can put our site offline, and only the developer can vie

Preg_match unknown modifyer
Hello,

Im trying to write a little script for my forums i need to get the reply from my forum

On page view, minus credit
Hello all, please, I need a little help with this script. I am charging one credit (credits can be p

Recording popularity by day, week.. all time?
Hey everyone, I'm creating a site designed around users uploading music. How can I implement a syste

Mysterious Timeouts
I've deployed a few simple AJAX-enabled web page to a local server that is accessed through the Inte

can i optmize image to 50% quality before uploading 2 server
Hi there

i have jus written a php program to upload and display images but when i try to uplo

Problem with variable declaration in switch statement
Hello, I am having some trouble assigning a value to a variable inside a switch statement. What I a

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