Activity › Forums › Web Design (WordPress, Joomla, etc.) › PHP Text input as checkbox
-
Abraham Chaffin
January 4, 2011 at 6:20 pmWell – I guess that’s one reason why it’s better to pass an id with your key rather than a text description.
Do you have a numeric product id you could pass and then tie it back to the description on the other side of the posting?
If not you could do something like this:
<?
//SET YOUR ID TO ZERO BEFORE THE LOOP
//USE THE ID TO MATCH PRODUCT INFORMATION AFTER POSTING
$id++;
?>
<?=$row_Recordset1['description']?>: <input type='text' size=2 value='' name="product_qnty_<?=$id?>" />
<input type='hidden' name='product_desc_<?=$id?>' value="<?=$row_Recordset1['description']?>" />This isn’t really the best way at going at this but since I don’t know your entire setup it helps fix what you’re trying to do.
Altered processing:
<?
//KEY FOR QUANTITY FIELDS
$qnty_key=”product_qnty_”;//LOOP THROUGH THE POST FIELD
foreach($_POST as $key => $val)
{
//IF THE BEGINNING OF THE POST FIELD IS THE QUANTITY KEY AND THE VALUE IS A NUMBER AND THE NUMBER IS OVER ZERO
if(substr($key,0,strlen($qnty_key))==$qnty_key && is_numeric($val) && $val > 0)
{
$id=substr($key,strlen($qnty_key));
$prod_description=$_POST[‘product_desc_’.$id];
echo $prod_description.”: “.$val.””;
}
}
?> -
Richard Williams
January 4, 2011 at 7:16 pmthanks man
Richard Williams
p.s. Please remember to rate our post replies and tick if solved. Also, please remember that we here are NOT employed by Adobe, we do this out of love and fun, so its always nice to recieve a Please and Thank You! :o)
Reply to this Discussion! Login or Sign Up