Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New Coder
    Join Date
    Jun 2010
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts

    retrieve data and display

    Hi

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


    PHP Code:
    <?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 Code:
    <?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

  • #2
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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!

  • #3
    New Coder
    Join Date
    Jun 2010
    Posts
    59
    Thanks
    0
    Thanked 0 Times in 0 Posts
    anyway to show multiple news?

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

    anyway thanks for the reply.

  • #4
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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.

  • #5
    New Coder
    Join Date
    Nov 2010
    Location
    Kenya
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Make the change below and the multiple marquee will go.

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

  • #6
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    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.

    PHP Code:
    <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.

  • #7
    New Coder
    Join Date
    Nov 2010
    Location
    Kenya
    Posts
    42
    Thanks
    4
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Keleth View Post
    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.

    PHP Code:
    <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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •