Page 1 of 1

offset div style

Posted: Mon Jun 27, 2005 5:49 pm
by ol4pr0
Trying to do the following
instead of the ceil($row / $numrows) i do something like this.

Code: Select all

foreach($result as $row) {
$offset = 262;
	<div style="background:#000000;position:absolute; left:158px; top:<?php echo $offset+120;?>px; width:475px; height:10px;"></div>
}
However.. it not doing what i want.
This will generate only one block while it should generate a lot

Posted: Mon Jun 27, 2005 6:07 pm
by Burrito
are you trying to add incrementally to $offset?

you're redifining the var in each iteration of the loop and just adding 120 to it...

not sure what you want it to do, but if you want it to remember the new value on the next iteration, you're going to have to redefine it with the new value.

Posted: Mon Jun 27, 2005 6:14 pm
by ol4pr0
you mean something like this

Code: Select all

$offset = 262;
$i = 120;
foreach ($result as $row) {
	 $i .= $i+120;
		?>
		<div style="background:#000000;position:absolute; left:158px; top:<?php echo $offset+$i;?>px; width:475px; height:10px;"></div>
		<?
}

Posted: Mon Jun 27, 2005 6:17 pm
by Burrito
no .= just =.

$i = $i + 120;

Posted: Mon Jun 27, 2005 6:21 pm
by John Cartwright
or $i += 120

Posted: Mon Jun 27, 2005 6:24 pm
by Burrito
Jcart wrote:or $i += 120
yes this is better....go JCart!

Posted: Mon Jun 27, 2005 10:11 pm
by ol4pr0
Well i was trying using css to make some columsn instead of the old fashion way.

Wasnt happy with the layout..

But seems that i cant do that. i can make columns tho.
but cant seem to make it increment correctly.
ej

1st $row 2nd $row 3rd $row
--------____--------___--------

Code: Select all

for($i = 0; $i < $rows; $i++) {
			for($j = 0; $j < $columns; $j++) {
				if(isset($data[$i + ($j * $rows)])) {
					$y += 120;
					?>
					<div style="background:#000000;position:absolute; left:158px; top:<?php echo $offset+$y;?>px; width:230px; height:110px;color:#ffffff"><img src="<?php echo $data[$i + ($j * $rows)];?>" height="110" width="95"></div>
					<div style="background:#000000;position:absolute; left:400px; top:<?php echo $offset+$y;?>px; width:230px; height:110px;color:#ffffff"><img src="<?php echo $data[$i + ($j * $rows)];?>" height="110" width="95"></div>
					<?
			}
			
		}
	}
Will show the same data twice :(

Code: Select all

#this does work .. kinda but will have a stairway effect.
# starts at 158 px for first column but 2nd +300 repeating itself 158px|458px
<div style="background:#000000;position:absolute; left:<?php echo $zOff+$z;?>px; top:<?php echo $offset+$y;?>px; width:230px; height:110px;color:#ffffff"><img src="http://www.opErtunidades.com/<?php echo $data[$i + ($j * $rows)];?>" height="110" width="95"></div>