Advanced Search

Results 1 to 5 of 5

Thread: data output help

  1. #1
    Join Date
    Sep 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default data output help

    Hi all

    I have a script that inputs a link into a database.

    the date, li class, url, title and comment are added tot he database.

    Outputting these values is fine, but what i want to do is output each set of links under the day they were added. like so


    Tuesday 12th
    link1
    link2
    link3
    link4

    Monday 11th
    link 1
    link2
    link3
    link4


    all i keep getting is


    tuesday 12th
    link
    tuesday 12th
    link


    can anyone help point me int he right direction?

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I think we'd need the script as well.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Sep 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    <?php
    $con = mysql_connect("*****","*****","*****");
    if (!$con)
    {
    die('Could not connect: ' . mysql_error());
    }

    mysql_select_db("*****", $con);
    $result = mysql_query("SELECT * FROM info ORDER BY id DESC");

    while($row = mysql_fetch_array($result))
    {
    $date = $row["date"];
    $liclass = $row["class"];
    $url = $row["url"];
    $title = $row["title"];
    $comment = $row["comment"];


    echo "<li class='$liclass'><a href='$url' target='_blank'>$title</a>.<br /> $comment </li>"; ; echo "\n";

    }
    mysql_close($con);
    ?>
    <?php
    echo '</ul>';
    ?>


    so far that is all i have managed. basically the script will be a link archive. only one month is visible on the page and each day of that month, previous months are then archived.

  4. #4
    Join Date
    Sep 2005
    Location
    India
    Posts
    1,626
    Thanks
    6
    Thanked 107 Times in 107 Posts

    Thumbs up

    PHP Code:
    <?php
    $con 
    mysql_connect("*****","*****","*****");
    if (!
    $con)
    {
    die(
    'Could not connect: ' mysql_error());
    }

    mysql_select_db("*****"$con);
    $result mysql_query("SELECT * FROM info ORDER BY id DESC");

    $dateChk 0;
    while(
    $row mysql_fetch_array($result))

    $date $row["date"];
    $liclass $row["class"];
    $url $row["url"];
    $title $row["title"];
    $comment $row["comment"];
    echo 
    "<ul>";
    If(
    $dateChk != $date)
    {
        echo 
    "$date<br><li class='$liclass'><a href='$url' target='_blank'>$title</a>.<br /> $comment </li><br>"
        echo 
    "\n";
    }
    else 
    {
    echo 
    "<li class='$liclass'><a href='$url' target='_blank'>$title</a>.<br /> $comment </li><br>"
    echo 
    "\n";
    }
    $dateChk $date;
    }
    mysql_close($con);
    ?>
    <?php
    echo '</ul>';
    ?>
    Basically it is your code itself. I've only introduced a new variable
    PHP Code:
    $dateChk 0
    if you check the while condition and the if statement in it you'll get the correct idea.

    Though i haven't checked but if your code is working then this should also work.

  5. #5
    Join Date
    Sep 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi

    that script works fine. the only problem i seem to be having is that each days date and list of links needs to be in a different UL

    the script above will print everything inside a single UL. how do i go about creating the following?

    <framset>
    <legend>Thursday 14th</legend>
    <ul>
    <li>Link here</li>
    <li>Link here</li>
    </ul>
    </framset>

    <framset>
    <legend>Wednesday 13th</legend>
    <ul>
    <li>Link here</li>
    <li>Link here</li>
    </ul>
    </framset>

Bookmarks

Posting Permissions

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