Creating a function
Posted on
16th Feb 2014 07:03 pm by
admin
Basically i wanna put all this code in a seperate file
Code: <?php
$query = "select product.ProductID, product.ProductName, product.ProductCategory, product.ProductPrice, product.ProductQuantity, product.ProductDescription, image.ImageID, image.ImagePath, image.ImageName, product_image.ImageID, product_image.ProductID
FROM product
JOIN product_image
ON product.ProductID = product_image.ProductID
JOIN image
ON image.ImageID = product_image.ImageID";
//Use this query below
$result = mysql_query($query, $conn)
or die ("Unable to perform query");
while($row= mysql_fetch_array($result))
{
$productname = $row['ProductName'];
$productprice = $row['ProductPrice'];
$imagename = $row["ImageName"];
$imagepath = $row["ImagePath"];
//Get the product id so i can pass it
$productid =$row["ProductID"];
$file = $imagepath.$imagename;
?>
<ol>
<li class="newproducts">
<!-- Make the product name clickable and pass through its id -->
<?php echo '<a href="product_details.php?productid='.$productid.'">' .$productname.'</a><br />';?>
<?php echo '<a href="'.$file.'" target="_blank" rel="lightbox"><img src="'.$file.'" width="100" height="100"/><br />';?>
<?php echo 'Price' . $row ['ProductPrice'].'<br /><br />';?>
</li>
</ol>
<?php
}?>
Then call it on the index page, how can i do this
No comments posted yet
Your Answer:
Login to answer
268
19
Other forums
How to find OS bit version
How can I tell the person browsing my site is running 32, or 64 bit operating system?
Issue Parsing XML into table
Hello all,
Im a bit new to php and new to phpfreaks. But thanks in advance for the help!
<
IS this code correct
The reason i ask is everything underneath it appears to be alink as well, tis blimmin annoying
Help with PHP and checkboxes
I am posting this for a friend of mine, i wrote a small script for her to process her form data to a
path to include folder
Hi everyone,
When I'm testing locally, I have to add the name of the site folder as part of t
Alternate messaging
I have 4 strings in MySQL db1
$string1 : Hello
$string2 : Hi
$string3 : Great
$strin
Newb advice
Hi all,
I'm a flash front end designer and I've taken on a project that needs some back end p
Serial number of exernal hard disk/Thumbdrive
Hi guys,
I am new tio java networking concepts.Please tel me how to get Serial
number of exernal
Curly Bracket Delimeters.
I'd always believed that the starting and ending delimeters in preg_ functions had to be the same ch
How can I uploading Transactional Data from Legacy to New SAP system
Hell Gurus,
I am overwhelmed with questions on how to migrate huge volume of Sales Orders