Page 1 of 1

div id=name increment

Posted: Wed Sep 01, 2010 9:58 pm
by prue_
hi, can someone help me.. I have a script (scroll text) and I need to pull dynamic data from the database.. "<div id="content" style="display:''">" id=content has to increment.. content0, content1, content2 and so on.. thanks!

Code: Select all

    $result=mysql_query($query); 
    $num=mysql_numrows($result); 
    $i=0; 
    while ($i < $num) { 
    $post_name=mysql_result($result,$i,"post_name");
    $postcontent=mysql_result($result,$i,"post_content"); 
	$posttitle=mysql_result($result,$i,"post_title"); 
    $snippet=substr($postcontent, 0, 50) . "...";
    $ID=mysql_result($result,$i,"ID"); 
<div id="content" style="display:''">
	<?php echo "<a href = \"index.php/?p=$ID\"><b>$posttitle</b></a>"; ?> <? echo $excerpt . "<a href = \"index.php/?p=$ID\">more</a>"; ?>
</div>
    <? 

	++$i; 
    } 

Re: div id=name increment

Posted: Wed Sep 01, 2010 10:59 pm
by requinix
Hint:

Code: Select all

$i = 0;

echo $i++;
echo $i++;
echo $i++;

Re: div id=name increment

Posted: Thu Sep 02, 2010 3:02 am
by prue_
thanks for your reply but I already tried that.. what I want to increment is the div id <div id="content" style="display:''">..

e.g static data
<div id="content0" style="display:''">
message sroll ONE
</div>

<div id="content1" style="display:''">
message sroll TWO
</div>

here's my code: (problem.. it doesn't change data.. it should display message sroll ONE then message sroll TWO but my code display them both at the same time)

Code: Select all

<div id="content" style="display:''">
        <?php echo "<a href = \"index.php/?p=$ID\"><b>$posttitle</b></a>"; ?> <? echo $excerpt . "<a href = \"index.php/?p=$ID\">more</a>"; ?>
</div>
    <?

        ++$i;
    }
</div>
hope you could help me.. thanks!

Re: div id=name increment

Posted: Thu Sep 02, 2010 3:28 am
by requinix

Code: Select all

<div id="content" style="display:''">
Have you considered simply sticking the $i in there? Right after the "content"? With <?php tags, of course.

Re: div id=name increment

Posted: Thu Sep 02, 2010 4:08 am
by prue_
hey, thanks! problem solved! you're a great help... THANK YOU!