add select input field

add a select input field that has the value 'quantity' by default
other choices are
1
2
3


I think something like this
echo '<td>quantity:<input type="select" id ="quantity" name = "quantity['.$p['quantity'].']" value="'.$p['quantity']"'></td>
<?php
//connect to db first
//...
require_once('inc/common.php');

if( isset($_POST) && !empty($_POST) )
{
 foreach($_POST['productid'] as $id =>$v){
   $productid=$_POST['productid'][$id];
   $title=$_POST['title'][$id];
   $internalsku=$_POST['internalsku'][$id];
   dbquery("UPDATE products SET title = '$title',internalsku='$internalsku' WHERE productid = '$productid'");
 }
 echo "Updated";
 exit;
}
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
echo '<table>'; // this is echoing html //
$sql=dbquery("select * from products where folderid=120 order by productid desc"); // this selecting all products from db //
foreach ($sql as $p){ //unsure of this i think hes changeing sql to p//
echo '<tr><td>productid:<input type="text" id="productid" name="productid[' . $p['productid'] . ']" value="'.$p['productid'].'" style="width:500px;">'; // now lists all data in a table by product id//
echo '<td>title:<input type="text" id="title" name="title['.$p['productid'].']" value="'.$p['title'].'" style="width:500px;"></tr>';
echo '<td>title:<input type="text" id="internalsku" name="internalsku['.$p['productid'].']" value="'.$p['internalsku'].'" style="width:500px;"></tr>';
} // now lists all products by title //
echo '</table>'; // end of html table//
echo "<div><input type='submit' name='trigger' value='Submit' /></div>";
echo "</form>";
?>

Open in new window

LVL 1
rgb192Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Om PrakashCommented:
Try
echo 'quantity:<select id ="quantity" name = "quantity"><option>quantity</option><option>1</option><option>2</option><option>3</option></select>'
0
Om PrakashCommented:
using loop
<?php
echo "<select name=quantity>";
echo "<option value=". "0" .">Quantity</option>";
for($i=1; $i <= 3; $i++)   echo "<option value=". $i .">" . $i . "</option>";
echo "</select>";// Closing of list box
?>

Open in new window

0
rgb192Author Commented:
that makes select fields

look exactly like

" . $i . "

with NO numbers
0
hieloCommented:

<?php
//connect to db first
//...
require_once('inc/common.php');

if( isset($_POST) && !empty($_POST) )
{
 foreach($_POST['productid'] as $id =>$v){
   $productid=$_POST['productid'][$id];
   $title=$_POST['title'][$id];
   $internalsku=$_POST['internalsku'][$id];
   dbquery("UPDATE products SET title = '$title',internalsku='$internalsku' WHERE productid = '$productid'");
 }
 echo "Updated";
 exit;
}
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'">';
echo '<table>'; // this is echoing html //
$sql=dbquery("select * from products where folderid=120 order by productid desc"); // this selecting all products from db //
foreach ($sql as $p){ //unsure of this i think hes changeing sql to p//
	echo '<tr><td>productid:<input type="text" id="productid" name="productid[' . $p['productid'] . ']" value="'.$p['productid'].'" style="width:500px;">'; // now lists all data in a table by product id//
	echo '<td>title:<input type="text" id="title" name="title['.$p['productid'].']" value="'.$p['title'].'" style="width:500px;"></tr>';
	echo '<td>title:<input type="text" id="internalsku" name="internalsku['.$p['productid'].']" value="'.$p['internalsku'].'" style="width:500px;"></tr>';
	echo '<select name="quantity">';
	for($i=1; $i<=3; ++$i)
	{
		$selected = ($i==$p['quantity'] ? " selected='selected' " : "");
		echo "<option {$selected} value='{$i}'>{$i}</option>";
	}
	echo '</select>';
} // now lists all products by title //
echo '</table>'; // end of html table//
echo "<div><input type='submit' name='trigger' value='Submit' /></div>";
echo "</form>";
?>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rgb192Author Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.