从gridview数据或mySQL DB中检索行并在PopUp中显示

时间:2013-08-05 04:20:00

标签: php javascript jquery mysql

Current Grid View structure with View Anchor - I want to view a specific row after clicking on View anchor, data should be displayed in popup - javascript

使用View Anchor的当前网格视图结构 - 我想在点击View锚点后查看特定的行,数据应该在弹出窗口中显示 - javascript

以下是我的代码。我已经实现了PHP网格视图的功能,删除选项在顶部用查询字符串实现

现在我想要的是,点击视图后,它应显示javascript弹出窗口,其中包含该特定行的所有详细信息,并关闭选项

未获得的部分是 如何将数据从php / mysql传输到javaScript并在弹出窗口中显示 `     

if(isset($_GET['id'])){
    $id = $_GET['id'];
    //$x = 'confirm("Are you sure you want to delete this product")';
    //echo $x;
    mysql_query("DELETE FROM users WHERE id = '$id'");
    //echo "alert('Row Deletion Successful')";
}
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Table Display</title>

    <style>
table, td, th
{
border:1px solid green;
}
th
{
background-color:green;
color:white;
}
</style>
</head>
<body>

<table>
    <thead>
        <tr>
            <?php $result = mysql_query("SELECT id, CONCAT(title, ' ',  name) as FullName, email, mobile FROM users") or die(mysql_error()); 
            $row_count = 1;
            $row = mysql_fetch_assoc($result);
            echo '<td><input type="checkbox" /></td>';
            echo "<th> Sr. No </th>";
            foreach($row as $col=>$value)
            {

                echo "<th>";
                echo $col;
                echo "</th>";

            }
            ?>
            <th>EDIT</th>
        </tr>
    </thead>
    <tbody>
<?php 
mysql_data_seek($result, 0);
while($row = mysql_fetch_assoc($result)){
    echo "<tr>";
    echo '<td><input type="checkbox" /></td>';
    echo "<td>" . $row_count ."</td>";

    foreach($row as $key=>$value)
    {

    echo "<td>";
    echo $row[$key];
    echo "</td>";
}
    $row_count++;
    ?>

    <td>
            <a href="users.php?id=<?php echo $row['id']; ?>" onclick="return confirm('Are you sure you want to delete this product ?')" title="VIEW" class="icon-1 info-tooltip">VIEW | </a>
            <a href="users.php?id=<?php echo $row['id']; ?>" onclick="return confirm('Are you sure you want to delete this product ?')" name="delete">DELETE |</a>
            <a href="users.php?id=<?php echo $row['id']; ?>" title="EDIT" class="icon-5 strong-text info-tooltip">EDIT </a>
        </td>

    <?php


    echo "</tr>";
}   

echo "</table>";


?>


    </tbody>
</table>
</body>
</html>`

2 个答案:

答案 0 :(得分:2)

您可以使用此代码在弹出窗口中的记录中显示

 function openWin()
{
 myWindow=window.open('','','width=200,height=100');
 myWindow.document.write("<p>your code to display in table format</p>");
 myWindow.focus();
}
<a onclick="openWin();">Edit/Delete/View(any one)</a>

在document.write()方法中尝试这一点,在表格标签

中输入你的代码

答案 1 :(得分:0)

在页面中呈现特定视图(例如viewpageaddress.php?id = 7) 然后通过以下方式获取js中的内容:

$.get('viewpageaddress.php?id=7', function(cnt){/* show cnt in your popup */})