Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

PHP code snippet wanted.


Aceicol

Recommended Posts

Posted

Hi

 

I am trying to select a table from my db and get the information from that table to be displayed on the page. I am new to PHP so am unsure on how to do this.

 

<?php

$link_id = mysql_connect("localhost", "username", "password");

 

$query = "SELECT products_image FROM products;

 

Where $query > 0

{

 

echo "<img src=" . $query ."><br>";

 

}

?>

 

I know this is a rough effort but it is my first time, I was hoping some PHP guru would help me out on this. The desired effect would be to have every image that is in the products_image field of the products table displayed in a row.

 

Thanks in advance

Posted
$link_id = mysql_connect("localhost", "username", "password") or die('I am dead'); 



mysql_select_db('catalog', $link_id);



$result = mysql_query("SELECT products_image FROM products"); 



if(mysql_num_rows($result)>0) {

 echo '<table>';

 while($row=mysql_fetch_array($result)) {

   echo '<tr><td><img src="'.$row['products_image'].'"></td></tr>';

 }

 echo '</table>

}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...