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
Why do I get this error
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/a5488351/public_html/bbdemo.php on line 90Code:<?php session_start(); ?><?php require
Adding delete feature to my forum
Hello I am currently trying to add a delete feature to my forum. I believe I have everything built right but I am having some problems when debugging. I do not have PHP Designer 2008 and I am using
Running a cron job through PHP/Apache?!
Hello all,I have a PHP script which makes a cron file from user input. When i try to run the cron job via system() the job doesn't run, I suspect it has something to do with permissions. Any ideas on
foreach result into a single variable
Hi,I have this code... Code: [Select]foreach ($_POST['Interests'] as $interest => $value) { echo "Interests: $interest; Value: $value";}How do I store the multiple results in a
Displaying returned XML in another PHP page
I have an online payment form that will return XML given if a payment is successful or declines. I am using PHP cURL to do this, and it all works from the standpoint of approving or denying
Newb advice
Hi all,I'm a flash front end designer and I've taken on a project that needs some back end php.It's not completely greek to me as I write actionscript in flash which is an OO language.However... I
rename the file
File.txtCode: ***DOCUMENT***..DN:000044255..CB:..SN:..PY:2009..ED:LA..ED:Home..ID:***DOCUMENT***..DN:000044254..CB:..SN:..PY:2009..ED:LA..ED:Edition..PT:ID:Code: <?php$file = fopen($argv[1],
need help in dynamic select menu in php
hi i have created a dynamic select menu using php. i have a problem in that which is when the user select any value in that menu and press submit then it does not pass to next page.my code is
Connecion issue
Hi,For some reason, I keep getting this error when trying to connect:Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on...Warning: mysql_select_db()
RTF fomatting to email content
Im trying to sen an email with content is picked up from a rtf-file (file_get_contents('*.rtf'). Mail is sent correctly, but the formatting of the content includes rtf formatting like: