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 3 of 3
  1. #1
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Displaying query results

    Hi,

    i have a javascript scrolling text function, for a news scroller on my site, the news headings are returned from a database.

    I have a query which returns 8 different rows, is there anyway that i can print these results on screen, but in one row and not 8, without using any form of table.

    i have the following:-

    PHP Code:
    <?php

    require('database3.php');

    $query  "select * from monksc.news where id='26'";

    $result mysql_query ($query) or die (mysql_error());

    if (
    mysql_num_rows($result)>0

    {
    while(
    $row=mysql_fetch_array($result))
    {
    ?>

    <?php

    if(!isset($title)) 
    $title='';

    if (
    $title !== $row['title'])

    {
    print 
    '<img src="../images/trans.gif" width="50" height="1">';
    }

    ?>
    i think it's the code below which prints the results in rows, i need them in one.

    PHP Code:
    <a class="ticker" href="news_item.php?id=<?php echo rawurlencode($row['id']);?>"><?php print $row['title']; $title $row['title'];}}?>
    any help would be great.

  • #2
    New Coder
    Join Date
    Oct 2005
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts
    you could do the following

    put this in the while loop
    PHP Code:
    <?php
    $news_item 
    .= '<a class="ticker" href="news_item.php?id=' .  rawurlencode($row['id']) . '">' $row['title'] . ' ';
    ?>
    then print out the $news_item variable after the while loop

  • #3
    Kal
    Kal is offline
    Regular Coder
    Join Date
    Dec 2005
    Posts
    309
    Thanks
    0
    Thanked 0 Times in 0 Posts
    works a treat, thank you for your help.


  •  

    Posting Permissions

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