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 彩灯控制电路,会的加我QQ1482956179
  • ¥200 相机拍直接转存到电脑上 立拍立穿无线局域网传
  • ¥15 (关键词-电路设计)
  • ¥15 如何解决MIPS计算是否溢出
  • ¥15 vue中我代理了iframe,iframe却走的是路由,没有显示该显示的网站,这个该如何处理
  • ¥15 操作系统相关算法中while();的含义
  • ¥15 CNVcaller安装后无法找到文件
  • ¥15 visual studio2022中文乱码无法解决
  • ¥15 关于华为5g模块mh5000-31接线问题
  • ¥15 keil L6007U报错