Close

Results 1 to 4 of 4
  1. #1
    DF VIP Member wadgey's Avatar
    Join Date
    Apr 2002
    Location
    UK
    Posts
    729
    Thanks
    16
    Thanked:        24
    Karma Level
    317

    Default PHP recordsets a multiple rows

    I'm tearing my hair out on what I think is a simple problem.

    My query returns multiple rows. I know how many rows there are but what I want to do is to access each row in turn. Now I thought that my code puts the results into an array and I can access each element by:

    $row_sections[x][y];

    but something is going wrong.

    Any ideas?

    PHP Code:
    mysql_select_db($database_localhost$localhost);
    $query_sections "SELECT * FROM sections WHERE sections.window_type = '$type'";
    $sections mysql_query($query_sections$localhost) or die(mysql_error());
    $row_sections mysql_fetch_array($sections);
    $totalRows_sections mysql_num_rows($sections); 

  2. #2
    DF Probation Fusen's Avatar
    Join Date
    Mar 2004
    Location
    Kent Uni
    Posts
    3,672
    Thanks
    0
    Thanked:        0
    Karma Level
    566

    Default Re: PHP recordsets a multiple rows

    you seem to be missing a while loop to actually go through every row,

    I'd recommend reading http://uk.php.net/manual/en/function...etch-array.php
    [CENTER][FONT=Verdana][SIZE=2]Real pirates don't [I]STEAL[/I], they [/SIZE][/FONT][B][FONT=Verdana][SIZE=2]SHARE[/SIZE][/FONT]
    [/B][SIZE=1]Unless they are cunts, then they just leech...:happy:[/SIZE][/CENTER]

  3. #3
    DF VIP Member hxbro's Avatar
    Join Date
    Nov 2000
    Location
    Behind a wall
    Posts
    2,731
    Thanks
    4
    Thanked:        18
    Karma Level
    476

    Default Re: PHP recordsets a multiple rows

    PHP Code:
    mysql_select_db($database_localhost$localhost);
    $query_sections "SELECT * FROM sections WHERE sections.window_type = '$type'";
    $sections mysql_query($query_sections$localhost) or die(mysql_error());
    $totalRows_sections mysql_num_rows($sections);

    // loop through the results
    while ($row_sections mysql_fetch_array($sections))
    {
        
    // $row_sections contains the row

    Download my latest breaks and electro mixes or listen to Sellout Breaks FM

  4. #4
    DF VIP Member wadgey's Avatar
    Join Date
    Apr 2002
    Location
    UK
    Posts
    729
    Thanks
    16
    Thanked:        24
    Karma Level
    317

    Default Re: PHP recordsets a multiple rows

    thanks. I found and used this:

    mysql_result($sections, $i, "section_width_type"

    it seems to work. What exactly does this do?

Similar Threads

  1. Which multiple banee has pissed you off most?
    By ABCMan in forum Hall Of Shame
    Replies: 33
    Last Post: 23rd January 2003, 03:41 AM
  2. What kit would I need to receive multiple text msgs?
    By devs in forum Unlocking Questions & Solutions
    Replies: 1
    Last Post: 19th December 2002, 01:06 PM
  3. Multiple GI files
    By too2buff in forum Sony Consoles
    Replies: 1
    Last Post: 24th October 2002, 12:40 AM
  4. Multiple Game Installation Problems
    By spartyms2 in forum PC Gaming
    Replies: 5
    Last Post: 28th September 2002, 07:25 PM
  5. Multiple Games on 1 DVDR? Tools?
    By Phacman in forum Microsoft Consoles
    Replies: 7
    Last Post: 19th September 2002, 06:33 PM

Social Networking 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
  •