Anyone one around who is good with Arrays???
Posted: Sat Oct 01, 2005 1:53 am
feyd | Please use
Now I go through this array in steps and first want to identify all products with prod_cat="Hardware" and set their 'rused' element to '1'
The code does go into the loop but does not update the element in original array $relation but instead creates a new array instead. Can anyone let me know how to update the array element in the original array.
Thanks
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
Hi,
I have a query which generates an array from the database results returened:Code: Select all
$getrel = mssql_query('select * from products where vendor_code=151');
while($gotrel = mssql_fetch_array($getrel))
{
$relation[$gotrel[id]] = array ('id' => $gotrel[id],
'rvccode' => $gotrel[vendor_ccode],
'rvsname' => $gotrel[vendor_sname],
'rpcat' => $gotrel[prod_cat],
'rpnm' => $gotrel[prod_nm],
'rused' => '0');
}Code: Select all
$fld1 = 'rpcat';
while (list ($key, $val) = each ($relation)){
if ($relation[$key][$fld1] == 'Hardware') { $relation[$key]['rused'] = '1';
}
}Thanks
feyd | Please use
Code: Select all
andCode: Select all
tags where appropriate when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]