avario Posted December 4, 2009 Share Posted December 4, 2009 So I have this script, but when I try to execute it the page comes at blank. So I guess there is something wrong with the syntax, right? Here is the script: for ($x = 1; $x <= ($numrows + 20 - (20 * $pageNum)); $x++){ echo ' <tr> <td><center><img src="Photos/', $gallery,'/Thumbnails/', (1 + (($pageNum - 1) * 20))), '.jpg" class="thumbnail"></center></td>'; for ($c = 2; $c <= 4; $c++){ echo ' <td><center><img src="Photos/', $gallery,'/Thumbnails/', ($c + (($pageNum - 1) * 20))), '.jpg" alt="" width="150" height="150" class="thumbnail"></center></td>'; } echo ' </tr>'; if ($x >= 4){ break; } } Can someone please tell me what is wrong with it. I would really appreciate some help. Thanks. Link to comment https://forums.phpfreaks.com/topic/183943-something-wrong-with-my-for-code/ Share on other sites More sharing options...
rajivgonsalves Posted December 4, 2009 Share Posted December 4, 2009 1) The concatenation sign is "." not "," 2) you have some extra brackets <?php for ($x = 1; $x <= ($numrows + 20 - (20 * $pageNum)); $x++){ echo ' <tr> <td><center><img src="Photos/'. $gallery,'/Thumbnails/'. (1 + (($pageNum - 1) * 20)). '.jpg" class="thumbnail"></center></td>'; for ($c = 2; $c <= 4; $c++){ echo ' <td><center><img src="Photos/', $gallery,'/Thumbnails/'. ($c + (($pageNum - 1) * 20)). '.jpg" alt="" width="150" height="150" class="thumbnail"></center></td>'; } echo ' </tr>'; if ($x >= 4){ break; } } ?> Link to comment https://forums.phpfreaks.com/topic/183943-something-wrong-with-my-for-code/#findComment-971027 Share on other sites More sharing options...
PFMaBiSmAd Posted December 4, 2009 Share Posted December 4, 2009 echo accepts a comma separated list of parameters, so the commas are not necessarily the cause of the problem. Link to comment https://forums.phpfreaks.com/topic/183943-something-wrong-with-my-for-code/#findComment-971109 Share on other sites More sharing options...
shedokan Posted December 4, 2009 Share Posted December 4, 2009 The problem is the two extra ')' on lines 4 and 8. Link to comment https://forums.phpfreaks.com/topic/183943-something-wrong-with-my-for-code/#findComment-971200 Share on other sites More sharing options...
avario Posted December 4, 2009 Author Share Posted December 4, 2009 Thanks guys, it seems to be working without the extra bracket. The commas don't seem to be a problem though. Link to comment https://forums.phpfreaks.com/topic/183943-something-wrong-with-my-for-code/#findComment-971556 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.