Dimitar
Dimitar

Reputation: 1928

MySQL how to store more then one varible (string and/or int) using php?

So my idea is to store all those varibles (strings, int) in one place, like so:

'Address = "' . $_POST['address_city'] . $_POST['street'] . $_POST['number'] .  $_POST['block'] . $_POST['vhod'] . $_POST['etaj'] . $_POST['apartament'] . $_POST['msg'] '"'

The idea is that i want to store all those fields/varibles that come from a form in a POST and store all of them in the Address column. Any advices? Thank you!

Upvotes: 1

Views: 56

Answers (2)

Bhaskar Bhatt
Bhaskar Bhatt

Reputation: 1467

Fowing way you can store data to a variable

$strdata= 'Address = "' . addslashes($_POST['address_city'] . $_POST['street'] . $_POST['number'] .  $_POST['block'] . $_POST['vhod'] . $_POST['etaj'] . $_POST['apartament'] . $_POST['msg'] )."';

Upvotes: 1

Jerodev
Jerodev

Reputation: 33206

You could json_encode the $_POST variable. This way you can still do searches on this column using %LIKE%.

However, like Jigar said, it's much better to use a dedicated table or columns for your address fields. It will make the searching faster and the data more manageable.

Upvotes: 0

Related Questions