I'm new to SQL and PHP. Maybe I don't understand what you will answer, so please explain it fully that I can understand so here's my question
I have 5 columns: Id, Name, UserName, Password, valuie
You can understand 4 columns, the fifth is valuie means what the user want to give in wish list. Now when user select a thing and add into wish list, that's good but when he/she adds 2 things in his wish list, how to put that in valuie? how can I display 1st and 2nd value? I mean if I want to display 1st one and if 2nd and if both, what I can do about it?
My PHP is good but MySQL is not good....
Code
Insert into user(Name, UserName, Password, Valuie)
Values("bla bla", "blabla", "blabla", "here's 1st value", "here's second");
This seems like something that should be handled by a one-to-many relationship. A user can have many items in his wishlist. This means that you will need to split your current table up into two. Example: A user table and a wish list table:
user: id, name, etc.
wishlist: id, item_name, user_id
Whenever the user adds a new wish list item, it should be added to the wishlist table, keyed by his/her user_id.
Seeing as you are new to MySQL, you should make sure that you read up on the concept of database normalization.
you can use explode function for it, here is a example below, which will make you easier to understand..
suppose you have a field in your db as value=(value1,value2)
now you can fetch both of the these values one by one as following..
$data=explode(',',value);
//An Explode function gives you an array,
//by which you can get any desired value just by passing it's index.
$data1=$data[0];
$data2=$data[1];
Hopefully this would help you. Thanks.... :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With