Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Mysql query result manipulation

Options
  • 22-11-2004 11:26pm
    #1
    Registered Users Posts: 2,660 ✭✭✭


    Not sure if this belongs here but...

    I'm working away on a bit of a website when a technical question hit me on the head, and since I'm way away from looking at the application of the solution, I thought I'd find out if the solution was even possible (to save myself some lost time).

    There will be a couple of different menus on this site, each with its own sections to be displayed in them. When I run a query and the set of sections are returned, can I transfer from the returned "recordset" (I know thats asp jargon, but I dont know the php/mysql equivalent [yet]) some of the results into another "recordset" (or array) and then manipulate the new recordset knowing that I only have a subset of the original returned recordset in either location (not very good at explaining am I).

    For example:
    [php]
    sectionlist = mysql_query("select * from section;")
    [/php]

    will return the complete section list into the sectionlist variable, can I then Do something like this:
    [php]
    for(i = 0; i < sectionlist.length; i++)
    {
    if sectionlist.menuid ==1
    {
    subset = subset + sectionlist;
    delete(sectionlist)
    }
    }
    [/php]

    Hope thats clearer.

    Now I'm assuming I can build the second array (obviously not with that code [yes I know its bs code, so you don't need to correct it]) because it seems like a logical thing to be able to do, but can I manipulate the original array to delete each item as I add it to the new array??

    Just a simple overview is all I want, if its possible I'll investigate how, if not then you might be able to save me some time.

    Thanks in advance for any help.

    Baz_


Comments

  • Banned (with Prison Access) Posts: 16,659 ✭✭✭✭dahamsta


    Bit unclear tbh, so I'm just picking the only question I can find. :)
    can I manipulate the original array to delete each item as I add it to the new array?
    Yes, use unset($array[$element]).

    FYI, you don't need semicolons in SQL queries run by the PHP client.

    adam


Advertisement