如何检测对数据库所做的最新更新,并在发生更改时以静默方式刷新页面?
假设数据库访问如下:
$host = "localhost";
$username = "root";
$password = "root";
$db = mysql_connect($host,$username,$password) or die(mysql_error());
mysql_select_db('ccr') or die(mysql_error());
Run Code Online (Sandbox Code Playgroud)
任何想法和样品将不胜感激.谢谢.
我尝试在其中显示一些信息,<div>如下所示:
<div id="show_details" style="'display:block;' : 'display:none;'"> SHOW me
</div>
Run Code Online (Sandbox Code Playgroud)
通过从下拉选项中选择例如
<?php if ($books == 'art') { ?>
<option value="art" selected="selected" id="art_indicator" onchange="(this.selected) ? $('#show_details').css('display','block') : $('#show_details').css('display','none');">Art</option>
<?php } else { ?>
<option value="art" id="art_indicator" onchange="(this.selected) ? $('#show_details').css('display','block') : $('#show_details').css('display','none');">Art</option>
<?php } ?>
Run Code Online (Sandbox Code Playgroud)
和完整的代码如下,
<tr>
<td>Book Option</td>
<td>
<select name="books">
<?php foreach ($others as $other) { ?>
<?php if ($other == $other['other']) { ?>
<option value="<?php echo $other['other']; ?>" selected="selected"><?php echo $other['title']; ?></option>
<?php } else { ?>
<option …Run Code Online (Sandbox Code Playgroud)