Jump to content

For is not working


tobeyt23

Recommended Posts

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

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

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.