...

View Full Version : retrieve data and display



extremed
11-14-2010, 10:25 PM
Hi

Im trying to retrieve data from a mysql table and show them as news inside a
<MARQUEE></MARQUEE>



<?php
include ("object.php");

$sql = "select * from news_line where status='enable' order by date DESC";
$res = mysql_query($sql);
?>

so i used above query and display as this


<?php
while($dat=mysql_fetch_array($res)){
?>
<p><MARQUEE><?=substr($dat['news'],0)?></MARQUEE>
<?php
}
?>


it works but i can not manage to show news, one by one in one line

with this it shows several news in multiple MARQUEE


any help would be great.


Regards

Keleth
11-14-2010, 10:41 PM
First: aaaah!!! Seems to be a time machine to the 90's, with marquee tags again... Old, outdated, annoying. Regardless...

You have multiple marques because you're creating multiple marquees. If you want only one, put the opening tag before the loop, loop all the data in, then close the tag after the loop. Presto logic chango!

extremed
11-14-2010, 10:57 PM
anyway to show multiple news?

are you suggesting any new way to do this without MARQUEE tags?

anyway thanks for the reply.

Keleth
11-15-2010, 12:54 AM
Well, scrolling text either requires a marquee tag or javascript. Its just, it usually looks good to the designer but can be annoying for many users. Regardless... I told you how to put in multiple news items, open the tag, loop the data in, close the tag.

bngari
11-15-2010, 01:31 PM
Make the change below and the multiple marquee will go.



<?php
<MARQUEE>
while($dat=mysql_fetch_array($res)){
?>
<p><?=substr($dat['news'],0)?>
<?php
}
</MARQUEE>
?>

Cheers.

Keleth
11-15-2010, 04:10 PM
Your code is almost but not quite correct bngari. You put the marquee tags in the PHP, so they won't do anything there, and will cause errors. You either want them outside the PHP tags or echo'ed out in there.



<MARQUEE>
<?php while($dat=mysql_fetch_array($res)) { ?>
<p><?=substr($dat['news'],0)?><p>
<?php } ?>
</MARQUEE>


And I'm pretty sure paragraph tags, unless formatted inline (in which case, why not use span?), will cause the marquee items to appear on different lines.

bngari
03-13-2011, 11:56 AM
Your code is almost but not quite correct bngari. You put the marquee tags in the PHP, so they won't do anything there, and will cause errors. You either want them outside the PHP tags or echo'ed out in there.



<MARQUEE>
<?php while($dat=mysql_fetch_array($res)) { ?>
<p><?=substr($dat['news'],0)?><p>
<?php } ?>
</MARQUEE>


And I'm pretty sure paragraph tags, unless formatted inline (in which case, why not use span?), will cause the marquee items to appear on different lines.

oh yeah, it was a minor omission there. Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum