I have a page and an include file and im trying to make a function to make my code reusable.
original code in full that works
I tried spliting it up
this is in my include file
in proper page
original code in full that works
Code:
<?php
$result = mysql_query("SELECT price FROM catalogue WHERE item = 'whitetshirt'");
if (!$result) {
die("no such field");
}
$Row = mysql_fetch_array( $result );
$Displayprice = $Row['price']/100;
echo "£$Displayprice";
I tried spliting it up
this is in my include file
Code:
<?php
function itemdisplayprice(){
$Row = mysql_fetch_array( $result );
$Displayprice = $Row['price']/100;
// convert price from pence to pounds
echo "£$Displayprice";
}
?>
in proper page
Code:
<?php
$result = mysql_query("SELECT price FROM catalogue WHERE item = 'whitetshirt'");
if (!$result) {
die("No such feild");
}
itemdisplayprice
?>