SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2002
    Location
    New Zealand
    Posts
    1,021
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help Needed With Queries

    On my internet site's main page, I have the top story then list the rest of the stories:

    www.maccrazy.net/indexv4.php

    The thing is, I don't what the top story to appear below with the rest of the stories as well. How do I stop it loading this story?

    Any help would be great,

    Thanks

  2. #2
    SitePoint Addict BenANFA's Avatar
    Join Date
    Apr 2003
    Location
    Bath, UK
    Posts
    353
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Presumabley you have an ID for each story either in SQL add a WHERE clause

    ID != <TopStoryId

    or do a similar thing in php

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2002
    Location
    New Zealand
    Posts
    1,021
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have an ID for each story.

    Top Story Code:

    PHP Code:
    <?php

    //Important Data        

    $to "Very Important";

    //Select Data
    $importantquery =  "select * from inews_storydata where Importance like '%$to%' order by Date desc limit 1";

    //Run Query
    $importantresult mysql_query($importantquery);

    //Create Loop
    while ($top mysql_fetch_array($importantresult)) { 

    //Array turns out variables
    $topDate"".$top["Date"]."";

    $time_offset $GMT_Offset 3600;
    $topLong_Date date("d/m/Y",strtotime($Date)+$time_offset);
    $topID "".$top["ID"]."";
    $topTitle "".$top["Title"]."";
    $topTeaser "".$top["Teaser"]."";
    $topComment "".$top["Comment"]."";
    $topImage "".$top["Image"]."";
    $topVotes "".$top["Votes"]."";
    $topTotal "".$top["Total"]."";
    $topRating $topTotal $topVotes ;
    ?>
    General Story Code:
    PHP Code:
    <?php 
                    
                    
    //Headlines Data        

    //Select Data
    $query =  "select * from inews_storydata order by Date desc limit 15";

    //Run Query
    $result mysql_query($query);

    //Create Loop
    while ($headline mysql_fetch_array($result)) { 

    //Array turns out variables
    $Date"".$headline["Date"]."";
    $time_offset $GMT_Offset 3600;
    $Long_Date date("d/m/Y",strtotime($Date)+$time_offset);
    $ID "".$headline["ID"]."";
    $Title "".$headline["Title"]."";
    $Teaser "".$headline["Teaser"]."";
    $Comment "".$headline["Comment"]."";
    $Image "".$headline["Image"]."";
    $Votes "".$headline["Votes"]."";
    $Total "".$headline["Total"]."";
    $Rating $Total $Votes ;

    ?>
    For each, I just echo the information.

    Code:
    ID != <TopStoryId
    Does this go in the query?

  4. #4
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you could modify the second query like this
    PHP Code:
    $query =  "select * from inews_storydata WHERE ID != ".$topID." order by Date desc limit 15"
    - website

  5. #5
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    one tip then...
    PHP Code:
    $topID "".$top["ID"].""
    you don't need "". around, it is in fact rather bad, instead keep it like
    PHP Code:
    $topID $top["ID"]; 
    hope that helps...
    - website

  6. #6
    SitePoint Wizard
    Join Date
    Dec 2002
    Location
    New Zealand
    Posts
    1,021
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. Works perfectly

  7. #7
    ********* Member website's Avatar
    Join Date
    Oct 2002
    Location
    Iceland
    Posts
    1,238
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Good, good
    I have nothing more to say ...

    well, you have to fight for it :^D
    - website


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
  •