| | |
PHP Nested Loop Produces Redundant Records....
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Mar 2008
Posts: 36
Reputation:
Solved Threads: 0
I am having problems retrieving distinct records from a XML record. I am using the following code but seem to have the same image in an entire row. Thanks in Advance!
view demo code demo
view demo code demo
PHP Syntax (Toggle Plain Text)
<?php $display_number = 15; $tmp .= '<table width="100%" border="1" cellspacing="1" cellpadding="1">'; for ($i = 1; $i <= $display_number; $i++) { //this is the outer loop $tmp .= $i; #$thumb = $data['ysearchresponse']['resultset_images']['result'][$i]['thumbnail_url']; $tmp .= "<tr>"; $tmp .= "<td>".$i."</td>"; for($j = 1; $j <= 3; $j++) { // inner loop $thumb = $data['ysearchresponse']['resultset_images']['result'][$i]['thumbnail_url']; $tmp .= "<td>"; #$tmp .= $i * $j; $tmp .= '<img src="'; $tmp .= $thumb; $tmp .= '"/>'; $tmp .= $title; $tmp .= "</td>"; } $tmp .= "</tr>"; } $tmp .= '</table>'; ?>
here is something i would use to display 3 images to a row. maybe you can modify it.
there are a lot of unknown factors behind your code, so i kept it simple.
PHP Syntax (Toggle Plain Text)
<?php $table = '<table width="100%" border="1" cellspacing="1" cellpadding="1"><tr>'; $i = 0; foreach( $data['ysearchresponse']['resultset_images']['result'] as $value ) { if ( $i == 3 ) { $table .= '</tr><tr>'; $i = 0; } $table .= "<td><img src=\"{$value['thumbnail_url']}\" /></td>"; $i++; } $table .= '</tr></table>'; ?>
there are a lot of unknown factors behind your code, so i kept it simple.
Last edited by kkeith29; Nov 19th, 2008 at 12:50 am. Reason: forgot the freakin code. i am loosing it.
![]() |
Other Threads in the PHP Forum
- Previous Thread: dynamic page
- Next Thread: The "LIMIT" parameter in queries
Views: 691 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl customizableitems database date development directory display download dynamic echo email error file files folder form forms forum function functions google headmethod href htaccess html image include insert integration ip java javascript joomla jquery limit link login loop mail malfunctioning menu methods mlm mod_rewrite multiple mysql oop parse paypal pdf php problem query radio random recursion regex remote script search select server sessions sms soap source space speed sql structure syntax system table tutorial update updates upload url validation validator variable video web xml youtube






