| | |
My sql image links in table
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jan 2008
Posts: 20
Reputation:
Solved Threads: 0
How can i Load images in to each cell of a table based on its product id?
The picture url is stored in field: Product_picurl
I have looked around for a photogallery script but cant find one!!
Thanks in advance
The picture url is stored in field: Product_picurl
PHP Syntax (Toggle Plain Text)
SELECT `Product_id`,`Product_Name` , `Product_picurl` FROM `prod_listing` where `Product_id` ="$ID"
I have looked around for a photogallery script but cant find one!!
Thanks in advance
Last edited by duttydea; Jan 20th, 2008 at 4:20 pm.
1. execute your sql statement
2. use mysql_fetch_array to capture the data into an array (eg. )
3. Cycle through the array to output the image urls to the page with some sort of loop (foreach, for, while, whatever fits your script/writing style)
that's the theory behind it.
here's a little sample (very quick and messy mind you, but will help you get the idea):
that gets all the pictures into a table, in order.
to get them in some sort of order, try using the ORDER BY clause in your sql, such as in:
there are multitudes of other approaches you could use to improve this, but maybe this will give you a start.
2. use mysql_fetch_array to capture the data into an array (eg.
PHP Syntax (Toggle Plain Text)
$row=mysql_fetch_array($sql_result);
3. Cycle through the array to output the image urls to the page with some sort of loop (foreach, for, while, whatever fits your script/writing style)
that's the theory behind it.
here's a little sample (very quick and messy mind you, but will help you get the idea):
PHP Syntax (Toggle Plain Text)
//create sql $sql="SELECT * FROM prod_listing"; //execute query $result=mysql_query($sql,$connection) or die('could not execute query'); $html_content = '<table>'; while($row = mysql_fetch_array($result)) { $html_content .='<tr><td><image src="'.$row['Product_picur1'].'" /></td></tr>'; } $html_content.='</table>'; echo $html_content;
that gets all the pictures into a table, in order.
to get them in some sort of order, try using the ORDER BY clause in your sql, such as in:
$sql="SELECT * FROM prod_listing where Product_id ='$ID' ORDER BY some_field_here ASC;";there are multitudes of other approaches you could use to improve this, but maybe this will give you a start.
Last edited by johnsquibb; Jan 20th, 2008 at 6:10 pm.
![]() |
Similar Threads
- Error loading C:\Progra~1\bar\1.bin\MSWBAR.dll (Viruses, Spyware and other Nasties)
- Open In New Window Php (PHP)
- Infected, Please help!!! (Viruses, Spyware and other Nasties)
- vBulletin optimization (Search Engine Optimization)
- Generic Host Process for Win32 Services crash (Viruses, Spyware and other Nasties)
- Problems with LinkMaker Adware; "Server busy" pop ups and more (Viruses, Spyware and other Nasties)
- Amaena and winfixer problem (Viruses, Spyware and other Nasties)
- Pagination - not displaying results properly, please help! (PHP)
- Please help! (Viruses, Spyware and other Nasties)
Other Threads in the PHP Forum
- Previous Thread: Apache2.2 and php5.1.4 installation... pls help
- Next Thread: survey for school grads... Another question
| Thread Tools | Search this Thread |
301 access apache api array beginner binary broken cakephp checkbox class clean cms code compression countingeverycharactersfromastring crack cron curl database date decode directory display dissertation dropdown dynamic echo email error fairness file files folder form forms function functions google href htaccess html httppost image include insert integration ip javascript joomla limit link login mail match md5 menu methods mlm multiple mysql newsletters oop pageing pagerank paypal pdf php problem protocol query radio random recursion remote script search secure server sessions simple sms soap source space spam sql syntax system table tutorial update upload url validator variable video votedown web youtube





