Jump to content

2 issues with MySQL database


Recommended Posts

I have a very primitive version of a database set up using PHP/MySQL. I have a made a simple table with the columns 'name', 'age', 'address' & 'email'. The 'address' column has more tha one variable which is posted to it via a form (for example $_POST['street'] and $_POST['country']). When displaying the table on screen the field in the 'address' column has all the variables inline and all joined up. I was hoping to have the column display each $_POST variable on a new line, so it could appear like below......Example 135 Halgar Field CourtDunstableEnglandand not like what it currently displaying below..........Example 235 Halgar Field CourtDunstableEnglandAlso I am having problems getting data to display in the database from <select> tags and checkbox options users have submitted through the form.

------------------------------------------------------------------------------------

So my 2 questions are:1) Is it possible to have more than 1 $post variable in a MySQL table column and have each of those variables displayed on a new line like in Example 2?&2) How do I get <select> and checkbox options in a submitted form to display on a MySQL database?If you can help, you'd be a golden star :)

Link to post
Share on other sites
Is it possible to have more than 1 $post variable in a MySQL table column and have each of those variables displayed on a new line like in Example 2?
It doesn't matter that these happen to be variables in the $_POST array, and it doesn't matter that you are storing data in a MySQL database. All you're dealing with are strings. You can insert a newline with \n and then use nl2br to convert the newlines into HTML breaks, or you can just insert a <br> HTML tag.Select and checkbox values aren't any different then any other form value.<input type="checkbox" name="check" value="1">If they checked the box, then $_POST['check'] will be "1".<select name="list"><option value="1">1</option></select>If they choose option 1 then $_POST['list'] will be "1".
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...