I queried my dbase and got a result set that was put into an associative array that looks like this:
"ID" 2, "category" fabric, "color" red
"ID" 3, "category" clothes, "color" green
I want to then assign elements of the array to variables, but I can't figure out how to assign an element that is not in the first row of the array.
I used the following code for $item1:
$query2 = "SELECT * FROM inventory WHERE sale < 3";
$result2 = mysql_query($query2);
$row2 = mysql_fetch_assoc($result2);
$item1_id = ($row2['ID']);
So $item1_id == 2, my question is how would I assing $item2_id as "3"?
I have tried to use:
mysql_data_seek($result2,1);
$item2_id = ($row2['ID']);
but that does not work. I tried to use the "next" function, but that only moved the array to the next element (from "2" to "fabric") instead of moving to the next row of the array. I tried to use array_slice:
$item2_id = array_slice($row2['ID'], 2);
but that did not work either. I CANNOT FIGURE OUT HOW TO MOVE TO DIFFERENT ROWS OF AN ARRAY!!! Arrgh.