offset div style

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

offset div style

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post 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.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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>
		<?
}
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

no .= just =.

$i = $i + 120;
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

or $i += 120
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Jcart wrote:or $i += 120
yes this is better....go JCart!
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post 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>
Post Reply