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: &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

113 Like 24 Dislike
Previous php-forum Next php-forum
Other php-forum

Big Problem!! Please help
Hi Guys,

Im making a website for a friend have encountered a really annoying problem. When ev

Simple Question
I know this is a simple question, that if I knew what it was technically called i could probably loo

phpMailer not working ..........
HI,
I was playing with the phpMailer script and tried to send a smiple mail using their test scri

SOAP Issue
Hi,

I am facing some understanding problem with SOAP basic.kindly recommend some SOAP expert.

form problem
Hi all, I think this is going to be easy to resolve but for I have been looking at it to long and I

MySQL query problem
When I try to run the following piece of code, I get this error:
QuoteWarning: mysql_query(): sup

Array help
Hello i got this code to fetch data from database but it is not working it displays
7
Array

Can't find a decent web analytics!!!
I've downloaded and installed Piwik. It's location detection based on IP addresses is fairly inaccur

Setting/Modify Headers using mail() function
I have a question about setting email headers when using mail() in a php script.

When I send

mysql UNION | warning mysql_fetch_array !!
Code: <?php
$i = 0;
$query1="SELECT * FROM `products` WHERE `div

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