Jump to content

insert using implode


Yohanne

Recommended Posts

Hi coders,

 

getting hard to insert, according to the image below.

public function model_newtss($branch,$tssdate,$tss)
	{
		if($tss)
		  {
			foreach($tss as $tss_s)
				{
					$tsss[] = $tss_s;
				}
		}
            $_implode = "('".implode("'),('",$tsss)."')";
            $insert_tss = mysql_query("INSERT INTO code_tss(branch_id,tss_date,tss_trans_num) VALUES '$branch','$tssdate','$_implode'");
return $insert_tss;
       } 

 image.png

Link to comment
https://forums.phpfreaks.com/topic/287483-insert-using-implode/
Share on other sites

In image above "BRANCH" and "DATE" is not an array while "TSS #" is an array. 

BRANCH : <input type = "text" name = "branch" value = "">
DATE : <input type = "text" name = "date" value = "">
TSS NUMBER : <input type = "text" name = "tss[]" value = ""> //this line is, its up to a user how many input he/she want to add and defending on tss number. 

and now i am getting difficulties,  how to insert together array/implode and none array or base on image above. 

thanks.. and now i change the scenario and im going explore something and it is not working well and please please let help me to correct this line of codes and i know it is possible.

BRANCH : <input type = "text" name = "branch[]" value = "">
DATE : <input type = "text" name = "tssdate[]" value = "">
TSS NUMBER : <input type = "text" name = "tss[]" value = "">
USER : <input type = "text" name = "username[]" value = "">
public function model_newtss($branch,$tssdate,$tss,$username)
	{
	     if($this->model_newtss)
		 {
		     foreach($this->model_newtss as $tss_s)
		        {
		           $tsss[] = $tss_s;
		        }
		 }
	   $_implode = "('".implode("'),('",$tsss)."')";
           $insert_tss = mysql_query("INSERT INTO code_tss(branch_id,tss_date,tss_trans_num,empid) VALUES ".$_implode."");
	    return $insert_tss;
	} 
  • 2 weeks later...

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.