我需要从我的数据库中选择下拉列表(时间间隔)并且我坚持提交按钮,你能帮我吗?
的index.php
spark-shell
我的表格结构将是:
$ bin/spark-shell --packages com.databricks:spark-xml_2.11:0.3.0
你能帮我吗?
如果我想从列'register_date'中选择间隔。
2015-09-30 => 2015-10-01并输出sql查询中的所有列?
以下链接示例。我的“项目” http://54.187.150.122/php/index3.php
答案 0 :(得分:0)
您尚未为select元素指定名称,因此您无法发布值。使用方式如下:
<form action="" method="post">
<select name="register1">
<?php while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { ?>
<option value="<?php echo $line['register_date'];?>"><?php echo $line['register_date'];?></option>
<?php } ?>
</select>
<select name="register2">
<?php while ($line2 = mysql_fetch_array($result1, MYSQL_ASSOC)) { ?>
<option value="<?php echo $line2['register_date'];?>"><?php echo $line2['register_date'];?></option><?php } ?>
</select>
<input type="submit" value="get graph">
</form>
正如@Tom Regner所说,mysqli已被弃用,使用mysli或PDO
答案 1 :(得分:0)
这是代码..感谢您的帮助!这是100%的功能!
<?php
$con=mysql_connect("localhost", "user_sql", "pass_sql");
$db_select= mysql_select_db('db_name', $con);
$query="select * from tbl_name";
if ( !$con){
die('error: ' . mysql_error());
}
$result = mysql_query($query, $con);
$result1= mysql_query($query, $con);
?>
<form action="script.php" method="POST">
<select name="register">
<?php while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { ?>
<option value="<?php echo $line['id'];?>"><?php echo $line['id'];?></option>
<?php } ?>
</select>
<select name="register1">
<?php while ($line2 = mysql_fetch_array($result1, MYSQL_ASSOC)) { ?>
<option value="<?php echo $line2['id'];?>"><?php echo $line2['id'];?></option><?php } ?>
</select>
<input type="submit" name="submit">
</form>
<?php
if (isset($_POST['submit'])){
$query_graph="select * from tbl_name where id>='".$_POST['register']."' and id<='".$_POST['register1']."' ";
$result2= mysql_query($query_graph, $con);
echo "<table>";
while ($row = mysql_fetch_array($result2)){
echo "<tr><td>". $row['id'] ."</td>";
echo "<td>". $row['hours'] ."</td>";
echo "<td>". $row['node1'] ."</td>";
echo "<td>". $row['node2'] ."</td>";
echo "<td>". $row['register_date'] ."</td></tr>";
}
echo "</table>";
}
?>