Jump to content

Insert array into database


crims0nluv

Recommended Posts

Hello~

 

I have been trying to insert the post data into the database together with other some other information, but i couldn't seem to be able to insert it. I hope you all can help me :(

Here is my coding.

 

$this->post = $GLOBALS[HTTP_POST_VARS];

 

if (count($this->post))

{

$item=$this->post;

foreach ($item as $value) echo ($value.'<br>');

$tstring = implode(',' , $item);

$item_query=INSERT INTO idea_bank ($item) VALUES ('$tstring');

mysql_query ($item_query);

 

Other than this, I would like to insert another value which is $cid=$_GET['cid'];

So I would to insert this to. how do I go about??

Thanks!!!

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/79204-insert-array-into-database/
Share on other sites

i'd use, since i assume its 1 single post, this:

if (isset($_POST['some_key_value'])) {
mysql_query("INSERT INTO `table` SET `value` = '".$_POST['value']."', `othervalue` = '".$_POST['othervalue']."', `cid` = '".$_GET['cid']."';");
}

 

right now you're making 1 new row for each value posted to your script o_O

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.