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 Like 19 Dislike
Previous forums Next forums
Other forums

Search in the PHP Files
have to search asterisk(*) in the php code of the php files .
In the html page one text box

FAGL_FC_TRANSLATION FAS52 New GL ECC 6.0
Hello,

The new program for Translating GL Balances (FAS 52) gives the option to use diffe

max() problem
I have a while loop to get image names.
Code: $imagequery = mysql_query("SELECT * FROM ad_i

mr8m - reverse document
Friends,

I'm trying to reverse a document held by MIRO, but it reports the message balan

please help
HTML Code:

Code: <span id="ctl00"><span>

ECC6 - Single sign-on
We are in the process of upgrading to ECC 6 which will support single sign on with user passwords al

Using loop to count number of entries
I'm writing a program that must ask user to type in numbers. After each entry, the program has to re

Vertical Alligning - Not working in 1 cell?
<?php

echo "<table id="valign" width="60%" style=

php global variable
how can we create global variable so we can use its value in any form.. Please give example to

Getting number of affected rows in SQLPLUS..
Hi everyone,
I have a shell script where i am invoking sqlplus, running a query and saving t

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