fetch_array($postinfos)) { exec_switch_bg(); $postid = $postinfo['postid']; $tid = $posti ">

why just one row?

  • I am trying to retrieve some info from mysql, but why would the below query return just one row?

    $postinfos = $DB_site->query("SELECT * FROM post WHERE award=1 and visible=1 ORDER BY dateline DESC");

    $award = array();

    while ($postinfo = $DB_site->fetch_array($postinfos))

    {

    exec_switch_bg();

    $postid = $postinfo['postid'];

    $tid = $postinfo['threadid'];

    $uid = $postinfo['userid'];

    $date = $postinfo['dateline'];

    $username = $postinfo['username'];

    $title = $postinfo['title'];

    mysql_free_result($postinfos);

    }

    $threads = $DB_site->query("SELECT * FROM thread WHERE threadid=$tid");

    $threadid = array();

    while ($threadinfo = $DB_site->fetch_array($threads))

    {

    exec_switch_bg();

    $ttitle = $threadinfo['title'];

    $forums = $threadinfo['forumid'];

    mysql_free_result($threads);

    }

    $theforums = $DB_site->query("SELECT * FROM forum WHERE forumid=$forums");

    $forumid = array();

    while ($foruminfo = $DB_site->fetch_array($theforums))

    {

    exec_switch_bg();

    $forum = $foruminfo['title'];

    mysql_free_result($theforums);

    }


  • ok... can you tell me how to fix?


  • Because you keep overwriting the same data again and again and again.

    When you're in those while loops... assign the data you have to new parts of an array or something, but don't just change the value of static variables... you'll just overwrite what you did in the prior loop.







  • #If you have any other info about this subject , Please add it free.#
    Your name:
    E-mail:
    Telphone:

    Your comments:


    If you have any other info about why just one row? , Please add it free.

    7 January 2009 | cameltoepants.com | edit