tobeyt23 Posted February 22, 2007 Share Posted February 22, 2007 Want to display images 2 wide but seems my code breaks the variable up and shows the first 2 letters. What am I doing wrong? <?php if ($sqldatarow["category"]=="activelife") { for ($j=0; $j<8; $j++) { echo "<tr>\n"; for ($k=0; $k<2; $k++) { $cat = "activelife"; echo "<td><img src=\"_imgs/galleries/".$cat."/".$sqldatarow['filenamethumb'][$k].".jpg\" class=\"thumb\" alt=\"".$sqldatarow["alt"][$k]."\"></td>\n"; } echo "</tr>\n"; } } else { echo "<td> </td>\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/39657-for-is-not-working/ Share on other sites More sharing options...
JBS103 Posted February 22, 2007 Share Posted February 22, 2007 Sorry, just to clarify... The first two letters of what? The image URL? Link to comment https://forums.phpfreaks.com/topic/39657-for-is-not-working/#findComment-191452 Share on other sites More sharing options...
tobeyt23 Posted February 22, 2007 Author Share Posted February 22, 2007 it is taken the first 2 letters of the variable filenamethumb Link to comment https://forums.phpfreaks.com/topic/39657-for-is-not-working/#findComment-191455 Share on other sites More sharing options...
Orio Posted February 22, 2007 Share Posted February 22, 2007 Are you sure $sqldatarow['filenamethumb'] is an array? To me it seems that it is a string. When you do something like this, the $x'th char is outputted: <?php $string = "123abc"; $x = 2 echo $string[$x]; //Output- 3 ?> Check yourself. Orio. Link to comment https://forums.phpfreaks.com/topic/39657-for-is-not-working/#findComment-191461 Share on other sites More sharing options...
JBS103 Posted February 22, 2007 Share Posted February 22, 2007 It seems to me that $sqldatarow is not a multidimensional array or an array at all, therefore, by you coding $sqldatarow['filenamethumb'][0] and $sqldatarow['filenamethumb'][1], it is taking the first and second characters. I could be wrong so I am hoping someone else could come in and prove it either way, but I think that is how PHP handles a 2nd pair of brackets on a single dimension array. EDIT - Orio got to it. Link to comment https://forums.phpfreaks.com/topic/39657-for-is-not-working/#findComment-191463 Share on other sites More sharing options...
tobeyt23 Posted February 22, 2007 Author Share Posted February 22, 2007 So should i filenamethumb into any array then all 2 at a time that way? Link to comment https://forums.phpfreaks.com/topic/39657-for-is-not-working/#findComment-191486 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.