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. Quote Link to comment 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) Quote Link to comment 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. Quote Link to comment 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... Quote Link to comment Share on other sites More sharing options...
ronverdonk Posted September 13, 2006 Share Posted September 13, 2006 You're welcome.Ronald 8) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.