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

How to limit the calls to an API
Hello, in my simple script I call an api which effectively involves me getting an xml file.

H

Using Curl_multi for processing multiple URLs
Hi,

I am at a loss as to how to implement this. I would like to be able to automatically assi

explode() function problem maybe
Hi I'm having trouble searching my database. When I type two words in the search field it only searc

How to generate a random array of integers subject to a certain constraint
I am writing a program that asks the user to enter an integer N and then generates a random array of

Object Interfaces
EDIT: Never mind, I just updated to php 5.

Hey all,

I'm currently experimenting with p

Text file to .Dat file Conversion in PHP
Hi All,
Could anybody provide code for Text file to .Dat file Conversion in PHP.

Tha

Ajax not working on IE 6 for Windows CE
I've created a webpage which uses the classis Ajax in following format:view plaincopy to clipboardpr

timezone change with date()
so i put all my times for posts in my made from scratch forum(not phpbb3 or sm)
in my mysql db u

Really need helps regarding Pagination with Sort
I need someone helps regarding pagination problem...i actually want to make my page limited to let s

PHP5 - Verifying a secure mail is secure
I need to send an e-mail from a form to a external department and because it contains personal custo

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