1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2000
    Vejle, Denmark
    Rep Power

    When I'm making a mysql_query and running it through a while-loop (see below) some thing happen and I cannot reset this query and go on from the beginning - why is that?

    $query = mysql_query("....");
    while ($row = mysql_fetch_array($query)) {
    bla bla

    please help - or ask if you do not understand my question..
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Rep Power
    ok you have two options as far as i can see

    1. read all the query into an array but this depends upon the number of results in your query , i think u will need to set a new array for each result. This solution is really only viable for a few results.

    while ($row=mysql_fetch_array($query) {

    $myarray[$k] = $row[0];
    $myarray_two[$k] = $row[1];


    then when reading out the results do :-

    while (list($key, $value) = each ($myarray)) {

    echo $value;
    echo $myarray_two[$j];

    so once you have done this just reset the arrays



    2. call the mysql query

    while ($row=mysql_fetch_array($query) {

    blah blah

    and then call another query after this, but i dont reccomend this as it will mean sending two queries to the database etc.

    thats all i know i am sure someone else can improve on this


    visit http://www.itstop.com

    [This message has been edited by walshs (edited July 25, 2000).]

Similar Threads

  1. query syntax error
    By collegebloke in forum MS SQL Development
    Replies: 1
    Last Post: January 19th, 2004, 04:08 PM
  2. Overwriting mysql query with the query results
    By onerandomday in forum PHP Development
    Replies: 1
    Last Post: January 14th, 2004, 04:45 AM
  3. Syntax error in INSERT INTO query
    By Lee Miles in forum Visual Basic Programming
    Replies: 6
    Last Post: December 19th, 2003, 07:37 AM
  4. nested query and MySQL query
    By lucipher in forum MySQL Help
    Replies: 1
    Last Post: November 19th, 2003, 10:49 AM
  5. extremely inconsistent query times
    By mtnman in forum MySQL Help
    Replies: 0
    Last Post: October 23rd, 2003, 12:29 AM

IMN logo majestic logo threadwatch logo seochat tools logo