• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

建表单问题

php 搞代码 3年前 (2022-01-23) 17次浏览 已收录 0个评论
文章目录[隐藏]

我想建一个如下表单

菜鸟一枚,在网上找到类似的代码,修改一通,效果完全不是自己想的那样

希望实现功能,商品名列出数据库中全部商品,在选框中勾选代表要购买该商品,请求指点。 代码如下,

<meta http-equiv=”Content-Type” content=”text/html; charset=gbk” />
查询商品

<?php
include(‘conn.php’);//连接数据库。
mysql_query(“use sale_system”);
$sql=mysql_query(“select commodity from stock”);
$info=mysql_fetch_array($sql);

do{
?>

<?php
}
while($info=mysql_fetch_array($sql));
?>

购买 商品名 送单时段 订单备注
购买
<?php echo $info[‘commodity’]; ?> <?php echo $info[‘commodity’]; ?> 中午
下午
晚上

回复讨论(解决方案)

除了这个 没看出大问题
复选框用数组方式命名是对的
但 id 不能同名,否则用 js 操作时会有问题
值(value)应为商品的唯一识别信息(通常是id),不然就不知道买的是什么了

<meta http-equiv="Content-Type" content="text/html; charset=gbk" /><title>查询商品</title>  <tr valign="top" bgcolor="#FFFFFF">     <td height="81">      <table width="100%" border="0" cellpadding="0" cellspacing="0">        <tr>          <td height="79" align="center" valign="top"> <br>              <table width="356" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#625D59">                <tr align="center" bgcolor="#CC99FF">                  <td width="40">购买</td>                  <td width="40">商品名</td>                  <td width="40">送单时段</td>                  <td width="40">订单备注</td>                </tr>  <?phpinclude('conn.php');//连接数据库。mysql_query("use sale_system");$sql=mysql_query("select commodity from stock");$info=mysql_fetch_array($sql); do{    ?>                <tr align="left" bgcolor="#FFFFFF">        </tr>                  <td height="20" align="center">        购买</td>                  <td height="20" align="center"><?php echo $info['commodity']; ?></td>                  <td height="25" align="center">                      中午                      下午                      晚上                   </td>                </tr>                <?php}while($info=mysql_fetch_array($sql));?>             </table></td>        </tr>      </table>    <br></td>   </tr> </table> 

抱歉,上面发错了

<meta http-equiv="Content-Type" content="text/html; charset=gbk" /><title>查询商品</title>  <tr valign="top" bgcolor="#FFFFFF">     <td height="81">      <table width="100%" border="0" cellpadding="0" cellspacing="0">        <tr>          <td height="79" align="center" valign="top"> <br>              <table width="356" border="0" align="center" cellpadding="0" cellspacing="1" bgcolor="#625D59">                <tr align="center" bgcolor="#CC99FF">                  <td width="40">购买</td>                  <td width="40">商品名</td>                  <td width="40">送单时段</td>                  <td width="40">订单备注</td>                </tr>  <?phpinclude('conn.php');//连接数据库。mysql_query("use sale_system");$sql=mysql_query("select commodity from stock");$info=mysql_fetch_array($sql); do{    ?>                <tr align="left" bgcolor="#FFFFFF">                  <td height="20" align="center">购买</td>                  <td height="20" align="center"><?php echo $info['commodity']; ?></td>             <b>%本文@来源gao@!dai!ma.com搞$$代^@码!网</b><strong>搞代gaodaima码</strong>     <td height="25" align="center">                      中午                      下午                      晚上                   </td>                  <td height="20" align="center">备注</td>                </tr>                <?php}while($info=mysql_fetch_array($sql));?>             </table></td>        </tr>      </table>    </td>   </tr> </table> 

搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:建表单问题

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址