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 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突