Web Analytics Made Easy -
StatCounter basic sql help please!! - CodingForum

Announcement

Collapse
No announcement yet.

basic sql help please!!

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • basic sql help please!!

    Hi All,

    i need some basic help please,

    i am having trouble getting a list of info from a specific row in my database, i have checked the number of rows which returns the correct number but when i print out my results i am getting the first record print out 47 times instead of each of the 47 records printing out once.

    where am i going wrong with this?

    PHP Code:
    $sql "SELECT *
            FROM rss_feeds
            WHERE description = 'top'"
    ;
    $query mysql_query($sql);
    $row mysql_fetch_array($query);
    $rows mysql_num_rows($query);

        for (
    $i 0$i $rows$i++) {
    $feedURL[$i] = $row['s_FeedURL'];
    print 
    $feedURL[$i];
    print 
    "<br />";

    cheers

  • #2
    your question is likely not to do with sql but your php code. run your query directly in mysql client and see if it gives you correct rows. if it does you've just verified the problem is your output code.

    take a look in the php manual to make sure you are looping correctly.

    Comment


    • #3
      ok thanks mate,

      just checked the sql and its displaying the correct records,

      i will check the php manual to see if that helps

      cheers

      Comment


      • #4
        How about using while instead of for?

        PHP Code:
        $sql "SELECT * 
                FROM rss_feeds 
                WHERE description = 'top'"

        $query mysql_query($sql); 
        $row mysql_fetch_array($query); 
        $rows mysql_num_rows($query); 

            while (
        $i 0$i $rows$i++) { 
        $feedURL[$i] = $row['s_FeedURL']; 
        print 
        $feedURL[$i]; 
        print 
        "<br />"

        Comment

        Working...
        X