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 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献