dongyidao1461 2013-02-19 10:28
浏览 8
已采纳

保存运行时创建的文本框到mysql数据库[关闭]

Hi I am new to php. I am working on a form which creates a dynamic table when the page it opened the problem is that the table consist of the input text boxes which I don't have an idea to save it into my database I know the basic insert query but this one is a tricky part can anyone help me out here is my code

            <table border='0px'>
                <?php 
                $c = 1;
                $scomp = mysql_query("SELECT * FROM subject WHERE compulsory!='$c'")or die(mysql_error());
                $v =0;
                while($fsub = mysql_fetch_array($scomp)){

                $ycode = $fsub["code"];
                echo "<tr>";
                echo "<td width='200px'><font color='#FF6600'><strong>$fsub[name]</strong></td><td><input name='s_$ycode' type='text' size='1' maxlength='2'></td>";
                echo "</tr>";
                $v++;
                }
                 echo "<input id='hh' name='hh' type='text' value= '$v'/>";
                ?>
            </table> 
  • 写回答

1条回答 默认 最新

  • dongtuo0828 2013-02-19 10:37
    关注

    You are not using the concatenation operator for joining the strings with the variables. The concatenation operator in PHP is (.) the dot operator. Even when you run mysql query you will not get any records.

    Below is the correct syntax for your query

    $scomp = mysql_query("SELECT * FROM subject WHERE compulsory!= ".$c);

    below is your fixed code. Try it now

                $c = 1;
                $scomp = mysql_query("SELECT * FROM subject WHERE compulsory!=".$c)or die(mysql_error());
                $v =0;
                while($fsub = mysql_fetch_array($scomp)){
    
                $ycode = $fsub["code"];
                echo "<tr>";
                echo "<td width='200px'><font color='#FF6600'><strong>".$fsub[name]."</strong></td><td><input name='s_".$ycode."' type='text' size='1' maxlength='2'></td>";
                echo "</tr>";
                $v++;
                }
                 echo "<input id='hh' name='hh' type='text' value= '$v'/>";
                ?>
            </table> 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比