Jump to content


Photo

row count


  • Please log in to reply
4 replies to this topic

#1 crescent

crescent
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 30 April 2006 - 05:09 AM

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.

#2 OOP

OOP
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts
  • LocationSaudi Arabia

Posted 30 April 2006 - 07:06 AM

can you please post your code so that we can help you more.

thanks
<?php echo'The man who makes no mistakes does not usually make anything'; ?>

#3 crescent

crescent
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 30 April 2006 - 11:06 AM


Here is my table and code

:::::Table Structure::::

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::::





    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); 
}



Please tell me now I will I do that



#4 OOP

OOP
  • Members
  • PipPipPip
  • Advanced Member
  • 149 posts
  • LocationSaudi Arabia

Posted 30 April 2006 - 11:25 AM

Hi there,

can you put your form here as well...i am still confused a little it.
<?php echo'The man who makes no mistakes does not usually make anything'; ?>

#5 crescent

crescent
  • Members
  • Pip
  • Newbie
  • 8 posts

Posted 30 April 2006 - 12:27 PM

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


<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>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users