jjdave Posted September 13, 2006 Share Posted September 13, 2006 Hi All,I am reading Data into Array (id, part_no, part_desc, part_region etc.)[code=php:0]Example of Data: (Not PHP Code)ID | Part_no | Part_Desc | Region1 | 001 | Valve | CA2 | 121 | Union Nut | WA3 | 072 | Fitting | VA1 | 352 | O-ring | AZ[/code]I am running while loop so it reads the Array; Now, I like to print this data with one condition; If ID 1 is printed then next time it needs to skip if the same ID is repeated.So in example above, it should print only ID 1, 2, 3 and stop printing.Any help will be appriciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/20652-query-problemwith-condition/ Share on other sites More sharing options...
ronverdonk Posted September 13, 2006 Share Posted September 13, 2006 Firstly, sort the array on ID. Then print like:[code=php:0]$old_id = "";for ($i=0; $i<count($array); $i++) { if ($array['id'] != $old_id) { echo $array['id'] . ' ' . $array['part-no']... etc.; $old_id = $array['id']; }}[/code]Ronald 8) Link to comment https://forums.phpfreaks.com/topic/20652-query-problemwith-condition/#findComment-91315 Share on other sites More sharing options...
jjdave Posted September 13, 2006 Author Share Posted September 13, 2006 Thank you so much, I am trying out the code. Thanks again. Link to comment https://forums.phpfreaks.com/topic/20652-query-problemwith-condition/#findComment-91328 Share on other sites More sharing options...
jjdave Posted September 13, 2006 Author Share Posted September 13, 2006 Once Again, Thank You. It worked out great. Been at it for 3 Days, on and off... Link to comment https://forums.phpfreaks.com/topic/20652-query-problemwith-condition/#findComment-91337 Share on other sites More sharing options...
ronverdonk Posted September 13, 2006 Share Posted September 13, 2006 You're welcome.Ronald 8) Link to comment https://forums.phpfreaks.com/topic/20652-query-problemwith-condition/#findComment-91339 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.