duanchen7036 2014-12-30 06:28
浏览 51
已采纳

如何将值传递给php以获取表作为输出?

<script type="text/javascript">
    function OnSliderChanged (slider) {
        var sliderValue = document.getElementById (slider.id + "Value");
        sliderValue.innerHTML = slider.value;
    }

    function Init () {
        var slider = document.getElementById ("slider1");
        OnSliderChanged (slider);
        var slider = document.getElementById ("slider2");
        OnSliderChanged (slider);
    }
</script>
0<input type="range" id="slider1" min="0" max="100" step="1" style=width:50% onchange="OnSliderChanged (this)" />100
<span id="slider1Value" class="sliderValue"></span>
<br /><br /><br />
0<input type="range" id="slider2" min="0" max="100" step="1" style=width:50% onchange="OnSliderChanged (this)" />100
<span id="slider2Value" class="sliderValue"></span>
<br>
<input type="submit" onmouseover="this.style.cursor=\'pointer\';" OnMouseOut="this.style.cursor=\'default\';">


<?php
if (isset($_GET['value=20'&&'value1=40']))
{
$username = 'root';
$password = '';
$hostname = 'localhost';
$dataname = mysql_connect($hostname,$username,$password) or die("Connection failed: ");
$selected = mysql_select_db('testdb',$dataname) or die("Could not select table1");
$result = mysql_query("SELECT * FROM `table1`");
$last = '';
echo "<table>
    <tr>
        <th>id</th>
        <th>name</th>
    </tr>";
 while($row = mysql_fetch_array($result))
 {
 echo"<tr>
         <td>".$row['0']."</th>
         <td>".$row['1']."</td>
  </tr>"; 
  }
 mysql_close($dataname);
 }
else
{
echo " No Values Found";
}
 ?>

I am trying to get the input values into the php which should show the table.But am not getting the table as result am getting "No values Found" in the initial page itself. Am new to this php n javascript.. For eg i need to get the table when values 20 n 40 entered as input...Can someone please help me..?

  • 写回答

1条回答 默认 最新

  • doutu3352 2014-12-30 06:35
    关注

    You have to use name attribute in html form in order to access them in server side..

    0<input type="range" name="value" id="slider1" min="0" max="100" step="1" style=width:50% onchange="OnSliderChanged (this)" />100
    <span id="slider1Value" class="sliderValue"></span>
    <br /><br /><br />
    0<input type="range" name="value1" id="slider2" min="0" max="100" step="1" style=width:50% onchange="OnSliderChanged (this)" />100
    <span id="slider2Value" class="sliderValue"></span>
    <br>
    <input type="submit" onmouseover="this.style.cursor=\'pointer\';" OnMouseOut="this.style.cursor=\'default\';">
    

    Also make the form method to post with method="post"

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

报告相同问题?

悬赏问题

  • ¥15 我的数据无法存进链表里
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥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做蓝牙接受端