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

Did you know?Explore Trending and Topic pages for more stories like this.
$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 Like 19 Dislike
Previous forums Next forums
Other forums

Extract specific information from a PHP Multidimensional Array
Howdy! I've racked my brain over this for 24 hours now. I think it's time I asked for help. I'm lear

Images outside webroot
Im hopeing someone can help me with this because i cant figure it out.I have setup an ASP.NET websit

BI in Upstream Production operations
Appreciate if you can assist in the following areas:
1) Examples of life before and after BI i

Regarding accessing SQL query issued by any user in Oracle 10g
Hi all,
i want to know the queries issued by various users accessing a database...

media recovery
Hi,
i startup the database i got the error

SQL> startup
ORACLE instance started.

Solution Manager BPR
Does the SolMan-BPR-ARIS-Integration (http://www.ids-scheer.com/en/ARIS/ARIS_Platform/ARIS_Business_

Writing to the middle of a file
Hi I have a bit of a problem. Is there any way i can write some text to a middle of a text file. For

Install page
How do I make it so when a user submits information on the Install page, it'll right it into the cor

Alternate messaging
I have 4 strings in MySQL db1

$string1 : Hello
$string2 : Hi
$string3 : Great
$strin

php problem?
I don't think I'm stupid, but maybe I am.

I am working on a sit for a friend I am try to put

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