Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Mysql query result manipulation

  • 22-11-2004 11:26PM
    #1
    Registered Users, Registered Users 2 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
Advertisement