Hello all,
My question is how would you query (insert into table) a variables that can vary from few to many in quantity depending on the user input. The code looks like this.

$chkbox = $_POST['chk'];
$imp=$_POST['imp'];
$step= $_POST['step'];
$start=$_POST['start'];
$finish = $_POST['finish'];
$duration = $_POST['dur'];
$status= $_POST['status'];

foreach($imp as $a => $b){

 echo " imp: $imp[$a]  -  step: $step[$a] - start: $start[$a] - finish: $finish[$a] - duration: $duration[$a] - status: $status[$a] <br />";
}

There could be one row or many rows.
Any help is greatly appreciated.

Recommended Answers

All 4 Replies

hi

i write here how to insert the data using php

SYNTAX:

insert into tablename values("here the nameof the variable in which you fetch the data form text box","here the nameof the variable in which you fetch the data form text box",);

you can not understand then i wrte here eg

$connect=mysql_connect("localhost","root");
$db=mysql_select_db("user");
$name=$_GET["name"];
$num=$_GET["number"];
$in="insert into intro values('$name','$num')";
$result=mysql_query("$in");

still you not understand then refear the site http://www.w3cschool.com its good for you here you find your all problem

Member Avatar for rajarajan2017
foreach ($var as $a) { 
    $query = "INSERT INTO symbols (country) VALUES ('$a')";
    statements....
}

thanks rajarajan

I Agree with rajarajan07.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.