Cyber Posted March 10, 2006 Share Posted March 10, 2006 Hi.I`m trying to understand and use explode(), implode() from and to mysql db.Can someone SHOW me how to do the following code ??Please ?This is what i use to get the info into the db:[code]// This is a checkbox from a formecho '<input type="checkbox" value="'.$id.'" name="comfy[]"'; if(array_search("1",$comfy) > -1) echo ' checked="true"'; echo '>'.$cars_comfy.'<br>';//After submitting the form, i use implode$comfy= implode(',',$comfy);// That works okey enough, and in db it shows 1,2,3,4,5,6 and so on[/code]But then comes the tricky part, how to get it out again!?Thing is, that i am storing only numbers (like 1,2,3), and the value of those numbers is stored into another table.tablename: carsrow[0]: cars_idrow[1]: cars_comfySo you see that, i have to get out the numbers from the first table then the cars_comfy (output these names) to match the cars_id that is already uses implode on.Output would be (like i want it to be): A list:* carname1* carname2* carname3* and so on....Anyone that can help me make this script ?? Much easier to see a working example that reading from a text book.. hehe..Anyway, thank you so much =)Cyber Quote Link to comment Share on other sites More sharing options...
CyrusTh3VIrus Posted March 10, 2006 Share Posted March 10, 2006 If you would make it an array again you just have to use explode(',',$comfy);If $comfy is 1,2,3,4,5 the return of explode(',',$comfy); would be array(1,2,3,4,5);I hope this helps Quote Link to comment Share on other sites More sharing options...
Cyber Posted March 11, 2006 Author Share Posted March 11, 2006 Yes okey..Si if i do it this way..[code]<?php $puspus = explode(",",$sikkerhet); print_r($puspus); ?> Then this will output this:Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 )Cuz in db row it is inserted value 1,2,3,4,5,6,7,8[/code]But how to use these values ?That array is the ID to the value to another table in db, example 1 = Golf, 2 = BMW etc.So then i need a sql_query that get`s the value from both tables and out puts it like a list as wanted.But please show me how.. I do not know at all, tried to read it several times.. I know it is simple, but i can`t get it right.. please help.. Thanks again.Cyber Quote Link to comment Share on other sites More sharing options...
Cyber Posted March 11, 2006 Author Share Posted March 11, 2006 anyone ?Please !!Thanks Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 12, 2006 Share Posted March 12, 2006 Please post any code you have to show what your're trying to do.Ken 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.