retrieve data and display

Discussion in 'PHP' started by 3.5supersonic, Nov 14, 2010.

  1. #1
    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);
    ?>
    PHP:
    so i used above query and display as this

    <?php
    while($dat=mysql_fetch_array($res)){
    ?>
    			<p><MARQUEE><?=substr($dat['news'],0)?></MARQUEE>
                <?php
    }
    ?>
    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
     
    3.5supersonic, Nov 14, 2010 IP
  2. ThePHPMaster

    ThePHPMaster Well-Known Member

    Messages:
    737
    Likes Received:
    52
    Best Answers:
    33
    Trophy Points:
    150
    #2
    This is because you are printing marquee tags every time, it should only be printed once:

    
    <p><MARQUEE>
    <?php
    while($dat=mysql_fetch_array($res)){
    
    echo substr($dat['news'],0);
    
    }
    ?>
    </MARQUEE></p>
    
    PHP:
     
    ThePHPMaster, Nov 14, 2010 IP
  3. 3.5supersonic

    3.5supersonic Peon

    Messages:
    128
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    thanks ThePHPMaster
     
    3.5supersonic, Nov 14, 2010 IP