Jump to content

row count


crescent

Recommended Posts

I have created a submitting form from where user input his name and his choice (eg. pen, pencil, notebook). he have to choose two item from this three item. But the matter is if a item is already choosen by 10 user so that item will not be inputting into database table and he will get a massege.

any body help me please how will I set my logic and code.
Link to comment
Share on other sites


Here is my table and code

:::::Table Structure::::

[code]CREATE TABLE `_item` (
  `SL` int(11) unsigned NOT NULL auto_increment,
  `item_name` varchar(100) NOT NULL default '', PRIMARY KEY  (`SL`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;


CREATE TABLE `_name` (
  `SL` int(11) unsigned NOT NULL auto_increment,
  `user_name` varchar(100) NOT NULL default '', PRIMARY KEY  (`SL`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5;



[/code]




:::Code::::




[code]

    for($i=0;$i<count($_POST['i_name']);$i++)
    {
      
      $str=explode("#",$_POST['i_name'][$i]);
      $i_name=$str[1];
      if(($i_name<>""))
      {
    
      $sql="insert _item(item_name) values ('$i_name')";
      $rs=mysql_query($sql);
      }
      
    }
    


if($rs){
$sql1="insert into  _name(user_name) values ('$name')";
     mysql_query($sql1);
}

[/code]


Please tell me now I will I do that

Link to comment
Share on other sites

[b]:::::::::[!--coloro:#FF9900--][span style=\"color:#FF9900\"][!--/coloro--]Here is my form[!--colorc--][/span][!--/colorc--]::::::::[/b]


[code]<FORM name="f1" METHOD=POST onSubmit="return EW_checkMyForm(this);" ACTION="action.php">


<P align="center">
  <TABLE width="896" border=1 bordercolor="#FFC497">
    <!--DWLayoutTable-->
    <TR bgcolor="#E45F05">
      <TD height="23" colspan="6" align="center" valign="top"><FONT SIZE='2' face='verdana' color="#FFFFFF"><B>Add
        New Student Info.</B></FONT></TD>
    </TR>
    <TR>
      <TD width="38" height="28">&nbsp;</TD>
      <TD width="94">&nbsp;</TD>
      <TD width="247">&nbsp;</TD>
      <TD width="155">&nbsp;</TD>
      <TD width="69">&nbsp;</TD>
      <TD width="253">&nbsp;</TD>
    </TR>
    <TR>
      <TD height="26" colspan="2"><FONT SIZE='2' face='verdana'>Name</FONT></TD>
      <TD colspan="4" valign="top"><INPUT TYPE="text" cols=5 NAME="name" size="35"></TD>
    </TR>
    <TR>
      <TD height="26">&nbsp;</TD>
      <TD>&nbsp;</TD>
      <TD>&nbsp;</TD>
      <TD>&nbsp;</TD>
      <TD>&nbsp;</TD>
      <TD>&nbsp;</TD>
    </TR>
    <TR>
      <TD height="28" colspan="6" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</TD>
    </TR>
    <TR>
      <TD height="44" valign="top">SL</TD>
      <TD colspan="2" valign="top"><font size='2' face='verdana'>Choice</font></TD>
      <TD valign="top"><font size="2" face="verdana">Cost</font></TD>
      <TD>&nbsp;</TD>
      <TD>&nbsp;</TD>
    </TR>
    <TR>
      <TD height="28" valign="top"><font size='2' face='verdana'>1</font></TD>
      <TD colspan="2" valign="top"><font size='2' face='verdana'>
        <select name='i_name[]' id="i_name[]" onChange="setCredit(cr0,this.value)">
          <option value=''>Select one</option>
          <?php
        setCrList();
?>
        </select>
        </font></TD>
      <TD valign="top"><font size="2" face="verdana">
        <input name="cr0" type="text" id="txt1" value="0" size="25" >
        </font></TD>
      <TD>&nbsp;</TD>
      <TD>&nbsp;</TD>
    </TR>
    <TR>
      <TD height="28" valign="top"><font size='2' face='verdana'>2</font></TD>
      <TD colspan="2" valign="top"><font size='2' face='verdana'>
        <select name='i_name[]' id="i_name[]" onChange="setCredit(cr1,this.value)">
          <option value=''>Select one</option>
          <?php
        setCrList();
?>
        </select>
        </font></TD>
      <td valign="top"><font size="2" face="verdana">
        <input name="cr1" type="text" id="cr1" value="0" size="25">
        </font></td>

    </TR>
    <TR>
      <TD height="36" valign="top"><font size='2' face='verdana'>3</font></TD>
      <TD colspan="2" valign="top"><font size='2' face='verdana'>
        <select name='i_name[]' id="i_name[]" onChange="setCredit(cr2,this.value)">
          <option value=''>Select one</option>
          <?php
        setCrList();
?>
        </select>
        </font></TD>
      <td valign="top"><font size="2" face="verdana">
        <input name="cr2" type="text" id="cr2" value="0" size="25">
        </font></td>

    </TR>
    </TR>
    <TR>
      <TD height="47" colspan="6" valign="top"><div align="center"> <br>
          <input name="submit" type="submit" value="Submit">
          <input name="reset" type="reset">
        </div></TD>
    </TR>
    <TR>
      <TD height="12"></TD>
      <TD></TD>
      <TD></TD>
      <TD></TD>
      <TD></TD>
      <TD></TD>
    </TR>
  </TABLE>
</FORM>[/code]
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.