dongyi8416 2014-01-23 00:04
浏览 87
已采纳

在mysql数据库中输入一个数字范围

how to input a number range, from 2 text fields, this is my code is seems to be not working, the range function i want it to be inserted to mysql database but this code is just to test if i can get the 2 textfields to connect to the range function. anyone can help me solve this problem?

<?php
$from = '.from';
$to = '.to';
$number = range('$from','$to');
print_r ($number); 
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Waybill</title>
<link rel="shortcut icon" href="../img/icon.ico">
<link rel="stylesheet" type="text/css" href="../css/forms.css" />
</head>

<body>
<form id="form3" name="form1" method="post" action="">
  <p>From:
  <input type="text" name="from" id="form_number" class="from" value="0"/> 
    - To:
    <input type="text" name="to" id="form_number" class="to" value="50" />
  </p>
  <p>Waybill Booklet:
    <select name="waybill_booklet" id="form_list">
    </select>
  </p>
  <p>
    <input type="submit" name="button" id="form_button" value="OK!" />
  </p>
</form>

</body>
</html>
  • 写回答

1条回答 默认 最新

  • dougan7523 2014-01-23 00:18
    关注

    Replace your php code with this:

    <?php
    if (!empty($_POST)) {
        $from = $_POST['from'];
        $to = $_POST['to'];
        $number = range($from,$to);
        print_r($number);
    }
    ?>
    

    To access a form post in PHP you use the $_POST superglobal. More info found here: http://www.php.net/manual/en/reserved.variables.post.php.

    I've put a check to see if it's empty or not at the start, so when the page first loads it won't attempt to run the PHP code. Presumably you'll then replace the print_r with whatever you need to insert the data into your database.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用