Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

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

Avatar of Om Prakash
Om Prakash
Flag of India image

Try
echo 'quantity:<select id ="quantity" name = "quantity"><option>quantity</option><option>1</option><option>2</option><option>3</option></select>'
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

Avatar of rgb192

ASKER

that makes select fields

look exactly like

" . $i . "

with NO numbers
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

thanks