Jump to content

Adding multiple fields to a table


angryjohnny

Recommended Posts

Hi, I have been designing and coding (frontend html, javascipt CSS ) for over 6 years now and I'm just now taking the next step with building dynamic sites.

 

I have created a very simple database which has 6 Colums, I have created a page that displays the table and now I'm creating a page that the admin can add to the table.

My problem is this, I am able to write to two of the colums but when I go to try and write to a 3rd the database doesn't get updated. Here is my code that works.

 

if (isset($_POST['name']['bio'])) {

$name = $_POST['name'];

$bio = $_POST['bio'];

 

 

$sql = "INSERT INTO employee SET

name='$name',  bio='$bio' ";

 

 

 

This code above works but when I go to write add another colum (title) to be writen to it breaks.

 

if (isset($_POST['name']['title']['bio'])) {

$name = $_POST['name'];

$title = $_POST['title'];

$bio = $_POST['bio'];

 

 

$sql = "INSERT INTO employee SET

name='$name', title='$title', bio='$bio' ";

 

I know I'm not writing this properly, I have tried a few other ways but can't seem to get it right.

Any help would be most appreciated.

 

Thanks

John

Link to comment
https://forums.phpfreaks.com/topic/107491-adding-multiple-fields-to-a-table/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.