bizzo Posted April 3, 2006 Share Posted April 3, 2006 Hi,I have a database field which is taking text which is delimited by a | The data is going into the field from a multiple selection list. Now I need a way of reporting on the entered data.I was trying to use a do while loop to append data to the array which was created by the explode function, but as I found out the array is getting written over each time the loop is ran. At the moment my code reads[code]do {$arrayselect = explode("|", $row_infowouldlikebeincluded['infowouldlikebeincluded']);} while ($row_infowouldlikebeincluded = mysql_fetch_assoc($infowouldlikebeincluded));[/code]What I would like to happen is I need to count the number of times an individual row item occurs in the column. This item may be in a row with a delimited string e.g. Info|General Use or it may not be e.g. InfoI'm not sure how to go about this, any help is appreciatedThanksbiz Quote Link to comment Share on other sites More sharing options...
Desdinova Posted April 3, 2006 Share Posted April 3, 2006 I'm not sure what it is you want exactly, and I haven't worked with do/while loops.What you could try, is to change $arrayselect =, to $arrayselect[] =this way you'd create an array inside an array, not overwriting the data you had. Quote Link to comment Share on other sites More sharing options...
bizzo Posted April 3, 2006 Author Share Posted April 3, 2006 [!--quoteo(post=361133:date=Apr 3 2006, 05:34 PM:name=Desdinova)--][div class=\'quotetop\']QUOTE(Desdinova @ Apr 3 2006, 05:34 PM) [snapback]361133[/snapback][/div][div class=\'quotemain\'][!--quotec--]I'm not sure what it is you want exactly, and I haven't worked with do/while loops.What you could try, is to change $arrayselect =, to $arrayselect[] =this way you'd create an array inside an array, not overwriting the data you had.[/quote]Hi Desdinova,Thanks for your reply.When I change the array to $arrayselect[] and echo $arrayselect[$i] i get an output of "Array"What i would like to happen if each time the loop runs the value of the explode be appended onto the array.Thanks for your assistancebiz Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted April 4, 2006 Share Posted April 4, 2006 If I understand what you are trying to achieve try teh following...[code]<?php$arrsel = array();while ($row_infowouldlikebeincluded = mysql_fetch_assoc($infowouldlikebeincluded)) { $temp = explode("|", $row_infowouldlikebeincluded['infowouldlikebeincluded']); foreach ($temp as $value) { arraypush($arrsel,$value); }}?>[/code]use print_r($arrsel); to check the results. Quote Link to comment Share on other sites More sharing options...
bizzo Posted April 4, 2006 Author Share Posted April 4, 2006 [!--quoteo(post=361408:date=Apr 4 2006, 10:06 AM:name=ToonMariner)--][div class=\'quotetop\']QUOTE(ToonMariner @ Apr 4 2006, 10:06 AM) [snapback]361408[/snapback][/div][div class=\'quotemain\'][!--quotec--]If I understand what you are trying to achieve try teh following...[code]<?php$arrsel = array();while ($row_infowouldlikebeincluded = mysql_fetch_assoc($infowouldlikebeincluded)) { $temp = explode("|", $row_infowouldlikebeincluded['infowouldlikebeincluded']); foreach ($temp as $value) { arraypush($arrsel,$value); }}?>[/code]use print_r($arrsel); to check the results.[/quote]Thanks for your replyThis gets the values into an array which is what i needed...but...for some reason its leaving out all the records that are delimited by a | - is there a way I can include all records in the array even if they don't have a |Thanks 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.