动态生成的按钮PHP不工作
所以我在php上用循环动态创建了一些按钮 看起来像这样动态生成的按钮PHP不工作,php,jquery,html,mysql,Php,Jquery,Html,Mysql,所以我在php上用循环动态创建了一些按钮 看起来像这样 while($row = mysql_fetch_array($sql)) { $id = $row["DeviceID"]; $name = $row["Name"]; $description = $row["Description"]; $location = $row["Location"]; $image = $row["image"]; $dynamicList .= '<d
while($row = mysql_fetch_array($sql))
{
$id = $row["DeviceID"];
$name = $row["Name"];
$description = $row["Description"];
$location = $row["Location"];
$image = $row["image"];
$dynamicList .= '<div class="section">
<div class="container">
<div class="row">
<div class="col-md-6">
<img src="'.$image.'" class="img-responsive">
</div>
<div class="col-md-4">
<h1 class="text-success">The Light is ON</h1>
<h3>'.$_SESSION['Username'].'s '.$name.' ('.$location.')</h3>
<p>Light Location: '.$location.'<br>Light Description: '.$description.'<br><br><br><br><br>Intelligent Hours<br><br>Weekdays<br>7:00am - 7:45am <br>5:45pm - 7:30pm<br>8:30pm - 11:30pm<br><br>Weekends<br>TBD </p>
</div>
<div class="col-md-2">
<button type="submit" name="login" id="login" class="btn btn-default">Login</button>
<!--<button type="submit" name="button" id="button'.$id.'" value="'.$id.'" class="btn btn-default">Toggle Off</button>-->
</div>
</div>
</div>
</div>';
}
<?php
if(isset($_REQUEST['login']))
{
echo "<script type='text/javascript'>alert('button with Value = '.$value.'')</script>";
}
while($row=mysql\u fetch\u数组($sql))
{
$id=$row[“设备id”];
$name=$row[“name”];
$description=$row[“description”];
$location=$row[“location”];
$image=$row[“image”];
$dynamicList='
灯亮着
“.$”会话['Username'].'s'.$name.(“.$location.”)
灯光位置:“.$Location.”
灯光描述:“.$Description.”
智能时间
工作日
上午7:00-7:45
下午5:45-7:30
晚上8:30-11:30
周末
待定
登录
';
}
当我试图在用户触发它时捕获它时,它不起作用
我像这样捕捉它
while($row = mysql_fetch_array($sql))
{
$id = $row["DeviceID"];
$name = $row["Name"];
$description = $row["Description"];
$location = $row["Location"];
$image = $row["image"];
$dynamicList .= '<div class="section">
<div class="container">
<div class="row">
<div class="col-md-6">
<img src="'.$image.'" class="img-responsive">
</div>
<div class="col-md-4">
<h1 class="text-success">The Light is ON</h1>
<h3>'.$_SESSION['Username'].'s '.$name.' ('.$location.')</h3>
<p>Light Location: '.$location.'<br>Light Description: '.$description.'<br><br><br><br><br>Intelligent Hours<br><br>Weekdays<br>7:00am - 7:45am <br>5:45pm - 7:30pm<br>8:30pm - 11:30pm<br><br>Weekends<br>TBD </p>
</div>
<div class="col-md-2">
<button type="submit" name="login" id="login" class="btn btn-default">Login</button>
<!--<button type="submit" name="button" id="button'.$id.'" value="'.$id.'" class="btn btn-default">Toggle Off</button>-->
</div>
</div>
</div>
</div>';
}
<?php
if(isset($_REQUEST['login']))
{
echo "<script type='text/javascript'>alert('button with Value = '.$value.'')</script>";
}
啊,我意识到我没有放表单标签。我试试看是否有效again@A.Wolffatm我没有任何特定的“预期行为”,我只是在瞎弄弄弄按钮来解决NVM问题谢谢Norlihazmey,很抱歉浪费了你的时间