Results 1 to 3 of 3

Thread: MYSQL LIMIT command/option ?

  1. #1

    Join Date
    Sep 2002
    Location
    Auckland
    Posts
    1,356
    Rep Power
    17

    MYSQL LIMIT command/option ?

    Hello.

    I've got a strange issue. if I go into MYSQLadmin, & put this into my SQL query :-

    Code:
    SELECT *
    FROM `Clientlist`
    WHERE `Agent` =1
    it works fine, and brings up 10 entries from my database (there are only 10 entries)

    HOWEVER, it adds the LIMIT tag to the end of the query.

    Code:
    SELECT *
    FROM `Clientlist`
    WHERE `Agent` =1
    LIMIT 0 , 30
    if i put the same query into a test script, using mysqli (does only this one command), i only get ONE result.

    Does anyone have a theory why it only brings up one result in my PHP script in MYSQLI ?

  2. #2

    Join Date
    Sep 2002
    Location
    Auckland
    Posts
    1,356
    Rep Power
    17
    I've fixed the part where its only getting 1 line. Now i've got all the records.

    Code:
      $result = $mysqli->query($sql);
         if ($result = $mysqli->query("$sql"))
          {
    HOWEVER, I now have 10 x rows of 4 columns (this is good), i've got the data. HOWEVER, when i do print_r or something on the result, EACH COLUMN/FIELD of the result is its own array.

    so, i'm not getting 10 arrays with 4 bits of info in each one - i'm getting 40 arrays with 1 field in each one.

    ive used

    Code:
    $row = $result->fetch_array(MYSQLI_NUM);
    Code:
    $row = $result->fetch_array(MYSQLI_BOTH);
    Code:
    $row = $result->fetch_array(MYSQLI_ASSOC);

    Does anyone know how to get a "normal" / useful array of data ?

    Each row/line of my MYSQL results in its own array.

  3. #3

    Join Date
    Sep 2002
    Location
    Auckland
    Posts
    1,356
    Rep Power
    17
    solved.
    Code:
     while ($myrow = $result->fetch_row())
    {
      $aValue[]=$myrow;
    }
    (I tried that before, but for another reason, it didnt work. it now goes)

Posting Permissions

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