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
php title problem
Hi,
I am having a problem managing my page title with PHP.
Currently I have my <
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
How to ... (FAQs)
... get e-mail notifications
As several people asked how to get e-mail notifications when new posti
Calling strings from other php class
I have test1.php{
$string1;
$string2;
....
... //10 strings in this class <
button help
i originally had this but realised it is much easier to have a button.
Code: <?php
Upload, SSL and more php help
I recently just installed a ssl cert and do i use https for the whole site or just for the checkout.
Extracting Long text from message class with parameters
Hi,
I would like to extract the long text from a message class. However, the long text ha
ereg_replace in Wordpress
Heya - so I'm working on this site: http://world-of-smiles.theportlandco.com/new-patients
The
How to show more than 1 users with this code...
Hello,
i have a table that shows users only if I, as Administrator, want to be shown. But its sho
Comment Mod System Effects all rows...
Sorry if its confusing but here is whats going on: I have a table in a database called comments and