如何在弹出窗口中删除表代码?

时间:2013-06-10 08:17:38

标签: php popupwindow

第1步:我的弹出窗口脚本test.php。该脚本将调用index.php

function popup(){
var xhr=null;

if (window.XMLHttpRequest) { 
    xhr = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.onreadystatechange = function() {
  if(xhr.readyState == 4){ alert_ajax(xhr); }
 }
xhr.open("GET", "index.php", true);
xhr.send(null);
}
 function alert_ajax(xhr){
 var docAjax= xhr.responseText;
 r=confirm(docAjax);

    if (r==true)
        {
            window.location = "http://example.com";
        }
}
</script>

第2步:这是我的结果页面index.php

<?php

// 1. Create a database connection
$connection = mysql_connect("localhost","hanizar","abcde1122334455"); 
if (!$connection) {
    die("Database connection failed: " . mysql_error());
}

// 2. Select database to use 
$db_select = mysql_select_db("manage_projects",$connection);
if (!$db_select) {
    die("Database selection failed: " . mysql_error());
}

// 3. Perform database query
$result = mysql_query("SELECT survey_desc FROM subjects ORDER BY id DESC LIMIT 0,1",     $connection);
if (!$result) {
    die("Database query failed: " . mysql_error());
}

// 4. Use returned data


echo "<table border='1'> 
<tr> 
 <th> Name </th> 
 <th> Std code </th> 
 <th> TelePhone </th> 
 <th> Mobile </th> 
 <th> Email </th> 
 </tr>";

while($row = mysql_fetch_array($result)) 
{ 
echo "<tr>"; 
echo "<td>" . $row['survey_desc'] . "</td>"; 
echo "<td>" . $row['survey_desc'] . "</td>"; 
echo "<td>" . $row['survey_desc'] . "</td>"; 
echo "<td>" . $row['survey_desc'] . "</td>"; 
echo "<td>" . $row['survey_desc'] . "</td>"; 
echo "</tr>";

}

Echo "</table>"; 

mysql_close($connection);

?>

结果:我的弹出窗口将显示带有表格编码的结果。 问题:如何删除表格代码?

0 个答案:

没有答案