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

File upload issues
Hi Guys,

Can anyone see any issues with this code:
Code: $setImage= 'productimages/' . dat

Get ID from Database when Posting with a HTML Form
I have a form I am submitting to a MySql database. Each product has an ID # attached to it that auto

EU VAT Package 2010
Does any one know whether SAP will be developing new reporting functionality due the new VAT rules t

Upload Code Help
Hi everyone I need some help with a bit of code ive been working with for a while. I am completely s

distinct rows
Hi
version 10.2.0.3

I have a query output something like the following

ID

Join Query Help
Hi all,

I am having problems with the below code, which we shall call 'my first join query'!

Trying to add functions to table
I have this list of characters and I'm trying to figure out what I have to do to put the results of

Must-Know Topics of PHP
Can you guys list the must-know topics of PHP. I am still a learner and I am trying to cover most of

php sessions,logouts & the bloomin back button!
Hi All,

I've got a cms that members can log into. When they logout, the session is destroyed,

Update not working ... please help
Hi,

I am trying to update a row using an edit form by passing id of the row .. but it is not

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