Jump to content

[SOLVED] this " if .. else" statement doesn't work, please help !


vanvoquan

Recommended Posts

Hi everyone, I try to use this form for my site but the if and else statement doesn't work. I want my customers to chose for the quantity they desire and if they don't, the form automatic post an value of " 1 " to the quantity in the database. But for some reason, if my customers not chose the quantity, the form automatic post a " 0 " for the quantity in the database. Below is the code of the form, any help will be greatly appriciate. thank you.

			<tr>
  <?
   
	if($row['selling_method']=="auction" or $row['selling_method']=="dutch_auction")
{ 
if($row[Quantity] > 0)
{
?>
<form name="fix_form" action="detail.php" method="post">
<td height="27" class="banner1">Quantity</td><td>:</td>
    <td align="left">
<select name=qty <?if($row[Quantity]==0 or $row[status]=='Closed'){echo "disabled";}?>>
 <option value="Quantity">Quantity</option>
<? for($i=1;$i<=$row[Quantity];$i++)
{
?>
 <option value="<?= $i;?>"><?= $i;?></option>
<? 
}
?>
</select>
</td>
<? 
}
?>
    </tr>
     <?
     }
 else
 { 
 ?>
	 <input type="hidden" name="qty" value="1">
 <?
 }
 ?>

<tr>
	<input type="hidden" value="1" name="flag">
	<input type="hidden" value="<?= $err_flag; ?>" name="err_flag">
	<input type="hidden" value="fix" name="sell_method">
	<input type="hidden" value="<?= $item_id;?>" name="item_id">
	<input type="hidden" value="<?= $row[quick_buy_price];?>" name="fixed_price">
              <td class="banner1">Buy It Now Price</td>
              <td class="banner1">:</td>
              <td width="45%" class="detail888txt">US <?= $row['currency']; ?><?= $row['quick_buy_price']; ?>
&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="image" src="images/images/buyit.gif" name="Image70" value="buy" width="81" height="24" border="0" id="Image70" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image70','','images/images/buyito.gif',1)" onClick="return confirm_buynow(<?=$row[Quantity];?>)"; <?if(($row[Quantity]==0) or ($row[status]=='Closed') or ($today_date<0)){echo "disabled";}?>
</td>
</form>
            </tr>

Link to comment
Share on other sites

You can't use php like that .. it can't modify the form after printing it out.

 

But what you can do is have the php script that accepts the form check the quantity, and set it to 1 if it's not set in the form.

 

Edit: Alternatively, you can use javascript to set the value just before the form is submitted.

Link to comment
Share on other sites

Thanks for all the helps. With the guides from all of you, I fix the code and it works. Thanks so much.

if($qty==0)
{
$query="update placing_item_bid set status='Closed',Quantity='0',quantity_sold='1',sale_price=$fix where item_id='$item_id'";
mysql_query($query);
}
else if($qty >  0)
{
$query="update placing_item_bid set status='Closed',Quantity='$quantitans',quantity_sold='$qty',sale_price=$fix where item_id='$item_id'";
mysql_query($query);
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.