Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Using post in from...only one option is working.
Old 04-08-2010, 10:10 AM Using post Method in form. and ..only one action is working.
Isabella_Smith's Avatar
Ultra Talker

Posts: 285
Trades: 0
Hi forum,

I am having a problem with form in php........making an add and delete categories button in my form......................this is how I am doing it.

PHP Code:
<form name="category" id="category" method="POST" action="controller/business.controller.php">
<div class="divaddbiz">
                                          <table width="">
                                            <tr>
                                              <td width="199"><select name="cat[]" id="cat" multiple="multiple" size="10" style="width: 200px;">
                                                <?php
                                                                $bcat_sql
="select * from tblcat LIMIT 100";
                                                                
$result_bcat=mysql_query($bcat_sql);
                                                                while(
$row_bcat=mysql_fetch_array($result_bcat))
                                                                {
                                                                
?>
                                                <option value="<?=$row_bcat['category_id']?>" selected="selected">
                                                <?=$row_bcat['category']?>
                                                </option>
                                                <?php
                                                                
}
                                                                
?>
                                              </select></td>
                                              <td width=""><table align="center" cellpadding="0" cellspacing="0">
                                                  <tr>
                                                    <td width="20"></td>
                                                  </tr>
                                                  <tr>
                                                    <td><table width="64" border="0" align="left" cellpadding="0" cellspacing="0">
                                                        <tr>
                                                          <td width="6"><img src="img/btm-lt.jpg" width="7" height="28" alt="" /></td>
                                                          <td width="52" align="center" valign="middle">
                                                          <input name="insert" type="image" src="img/star-active.png" class="btm" value="Insert" /><input type="hidden" name="work" value="insertcat">
                                                          </td>
                                                          <td width="6" align="left"><img src="img/btm-rt.jpg" width="7" height="28" alt="" /></td>
                                                        </tr>
                                                    </table></td>
                                                  </tr>
                                                  <tr>
                                                    <td height="10"></td>
                                                  </tr>
                                                  <tr>
                                                    <td><table width="64" border="0" align="left" cellpadding="0" cellspacing="0">
                                                        <tr>
                                                          <td width="6"><img src="img/btm-lt.jpg" width="7" height="28" alt="" /></td>
                                                          <td width="52" align="center" valign="middle">
                                                          <input type="image" src="img/del.png" alt="delete" border="0" /><input type="hidden" name="work" value="deleteall"></a>
                                                          </td>
                                                          <td width="6" align="left"><img src="img/btm-rt.jpg" width="7" height="28" alt="" /></td>
                                                        </tr>
                                                    </table></td>
                                                  </tr>
                                              </table></td>
                                              <td width=""><select name="cat2[]" id="cat2" multiple="multiple" size="10" style="width: 200px;">
                                                  <?php
                                                            $bizcat_sql
="select * from tbltestbcc join tblcat t on tbltestbcc.cat_id = t.category_id where tbltestbcc.biz_id = '".$_GET['id']."' order by t.category asc";
                                                                
$result_bizcat=mysql_query($bizcat_sql);
                                                                while(
$row_bizcat=mysql_fetch_array($result_bizcat))
                                                                {
                                                                
?>
                                                  <option value="<?=$row_bizcat['category_id']?>">
                                                  <?=$row_bizcat['category']?>
                                                  </option>
                                                  <?php
                                                   
}
                                                  
?>
                                                </select>
                                                </td>
                                            </tr>
                                          </table>
                                      </div>
</form>
At the time of adding its working fine but when I goes to "Delete image" Its still stuck with the adding option...........sometime it works fine with delete and sometime with add.......both are not working accurately....

This is how I am controlling it..

PHP Code:
if($_POST['work']=="insertcat")
{    

    
$business = new business;

    if(!empty(
$_POST['cat']))
    {
    
        
$biz $_POST['bizval_f'];
        
$biz_city $_POST['city_cat'];
        
$cityname $_POST['cityname'];
        for(
$i=0$i<sizeof($_POST['cat']); $i++)
        {
        
        
$result $business->bcc_add($_POST['cat'][$i],$biz_city,$_POST['bizval_f']);        
        
//$list1[$i] = $_POST['cat'][$i];
                        
        
}
        if(
$result)
            {
        
        
$_SESSION["msg"] = "Categories added successfully.";
        
        
$url =  "../add_biz.php?id=".$biz."&amp;city=".$cityname;

        
header("Location: $url");
        
        die;

            }
        else 
            {
        
//$coupon->setsession($set);
        
$_SESSION["msg"] = "Error! unable to add subcategories.";
        
//header("Location: ../add_coupon.php");
        
print("<script language='javascript'>location.href='../add_coupon.php'</script>");
        die;
            }    

    }
}

if(
$_POST['work']=="deleteall")
{    

    
$business = new business;

    if(!empty(
$_POST['cat2']))
    {
    
        
$biz $_POST['bizval_f'];
        
$biz_city $_POST['city_cat'];
        for(
$i=0$i<sizeof($_POST['cat2']); $i++)
        {
        
        
$result $business->bcc_delete($_POST['cat2'][$i],$_POST['bizval_f'],$biz_city);        
        
//$list1[$i] = $_POST['cat'][$i];
                        
        
}
        if(
$result)
            {
        
        
$_SESSION["msg"] = "Subcategories Deleted successfully.";
        
        
$url =  "../add_biz.php?id=".$biz."&amp;city=".$cityname;

        
header("Location: $url");
        
        die;

            }
        else 
            {
        
//$coupon->setsession($set);
        
$_SESSION["msg"] = "Error! unable to Delete subcategories.";
        
//header("Location: ../add_coupon.php");
        
print("<script language='javascript'>location.href='../add_biz.php'</script>");
        die;
            }    

    }
}
else
{
$_SESSION["msg"] = "Error! work condition doesn't match.";
$url =  "../add_biz.php?id=".$biz."&amp;city=".$cityname;

        
header("Location: $url");
        
        die;

Please let me know where I mistook.....thanks for your help.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE



Please login or register to view this content. Registration is FREE
buy all indian salwar Kameez, Sarees and clothes

Last edited by Isabella_Smith; 04-08-2010 at 10:43 AM..
Isabella_Smith is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Using post in from...only one option is working.
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.09238 seconds with 12 queries