html中触发php代码
<div>
<form name="form1" method="post" action="">
<input name="button" type="reset" value="Flood" onclick="pstdatasearch.php"/>
</form>
</div>
<?php
// Get the search variable from URL
require_once('config.php');
//connect to your database ** EDIT REQUIRED HERE **
$connection=mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); //(host, username, password)
//specify database ** EDIT REQUIRED HERE **
mysql_select_db(DB_DATABASE,$connection) or die("Unable to select database"); //select which database we're using
// Build SQL Query
$result = mysql_query ("SELECT * FROM pstdisaster Where type = 'Flood'",$connection); // EDIT HERE and specify your table and field names for the SQL query
print "<table border='1'>";
print "<th align = 'center'>Name</th>";
print "<th align = 'center'>Type</th>";
print "<th align = 'center'>Date</th>";
print "<th align = 'center'>Location</th>";
print "<th align = 'center'>Level</th>";
print "<th align = 'center'>Government reaction</th>";
print "<th align = 'center'>Public response</th>";
print "<th align = 'center'>Sourse</th>";
print "<th align = 'center'>Damages</th>";
// now you can display the results returned
while ($row= mysql_fetch_array($result)) {
//echo "$count.) $title $title2 $title3 $title4 $title5 $title6 $title7 $title8 $nbsp; $title9" ;
// (5) Print out each element in $row, that is, print the values of
print "<tr> \n";
print "<td align = 'center'>{$row["name"]}</td>";
print "<td align = 'center'>{$row["type"]}</td>";
print "<td align = 'center'>{$row["date"]}</td>";
print "<td align = 'center'>{$row["location"]}</td>";
print "<td align = 'center'>{$row["level"]}</td>";
print "<td align = 'center'>{$row["Reaction"]}</td>";
print "<td align = 'center'>{$row["Responses"]}</td>";
print "<td align = 'center'>{$row["Sourse"]}</td>";
print "<td align = 'center'>{$row["damages"]}</td> <br> </n>";
print "</tr> \n";
// Print a carriage return to neaten the output
print "\n";
}
?>
我要的效果是 点击按钮 后再出现表单 而且之后还有多个按钮 点其他按钮会触发其他代码 覆盖之前输出的表格
追问:dcument.get是做什么用的? 我改成这样了 但是点击按钮 没任何动作 if之后语句不运行
<?php
$a=$_GET['act'];
if($a==1){ 原代码段}
else if($a==2){原代码段}
答案:<div id=info></div>
<input type=button onclick=pstdatasearch.php?act=1 />
<input type=button onclick=pstdatasearch.php?act=2 />
<?php
if(_GET('act')==1){
document.getElementById('info').innerHTML = 'aaaaaaaaaa';
}else if(_GET('act')==2){
document.getElementById('info').innerHTML = 'bbbbbbbbbbbbbb';}
?>
其他:var url= 设置一个公用DIV id=show.用JS的onclick触发后用AJAX去取得PHP内容,再用document.getElementById("show").innerHTML=返回的内容...这样就行了,这样当你每次触发,DIV里的内容都会改变... 用JS把
上一个:我是新手SEO菜鸟 请问wp dw php asp cms myspl dede 这些软件应该如何区分呀?
下一个:ecshop 头部所对应的php文件是哪个啊 求高手讲解 谢谢