动态显示模态窗口中的SQL查询结果

时间:2013-12-08 16:51:48

标签: php jquery mysql sql

我有一个联系人数据库,我根据用户的搜索请求填充表格中的详细信息。此外,当用户单击每行上的详细信息按钮时,它应打开模态窗口并显示该特定联系人的完整详细信息。我想为此目的使用/传递ID。后来我想使用传递的ID从DB查询完整的详细信息,需要在Modal窗口中显示完整的详细信息。请给我一些想法,以满足我的要求。

我的示例代码,

的search.php:

<table id="tbtest" align="center" width="1300" border="1" cellspacing="1" cellpadding="3" class="btable">

        <tr align="center" valign="middle">
            <td width="130" bgcolor="#CCCCCC"><strong>Last Name</strong></td>
            <td width="130" bgcolor="#CCCCCC"><strong>Calling Name</strong></td>
            <td width="180" bgcolor="#CCCCCC"><strong>Designation</strong></td>
            <td width="100" bgcolor="#CCCCCC"><strong>AGM Branch</strong></td>
            <td width="220" bgcolor="#CCCCCC"><strong>DGM Branch</strong></td>
            <td width="250" bgcolor="#CCCCCC"><strong>Office</strong></td>
            <td width="30" bgcolor="#CCCCCC"><strong></strong></td>

        </tr>


        <?php
            if ($fourth<>'') {$search_last_name = " AND (last_name LIKE '%".$fourth."%' OR calling_name LIKE '%".$fourth."%')";}
            if ($first<>'') {$search_agm_branch = " AND agm_branch='".$first."'";}
            if ($second<>'') {$search_designation = " AND designation='".$second."'";}
            if ($third<>'') {$search_office = " AND office='".$third."'";}

            if ($fourth<>'' OR $first<>''OR $second<>'' OR $third<>'') {
                $sql1 = "SELECT * FROM data WHERE id>0".$search_last_name.$search_agm_branch.$search_designation.$search_office;

                $sql_result = mysql_query ($sql1, $connection ) or die ('request "Could not execute SQL query" '.$sql1);}
            if (mysql_num_rows($sql_result)>0) 
            {
                while ($row = mysql_fetch_assoc($sql_result)) 
                {
        ?>

                <tr valign="middle">
                    <td><?php echo $row["last_name"];?></td>
                    <td><?php echo $row["calling_name"]; ?></td>
                    <td><?php echo $row["designation"]; ?></td>
                    <td><?php echo $row["agm_branch"]; ?></td>
                    <td><?php echo $row["dgm_branch"]; ?></td>
                    <td><?php echo $row["office"]; ?></td>
                    <td><input type="submit" name="button" id="<?php echo $row["id"];?>" value="Details" onClick="popupwindow()"></td>
                </tr>
                <?php
                }
            } 
            else 
            {
                ?>
            <tr valign="middle"><td colspan="6">No results found.</td></tr>

            <?php   
            }
            ?>
    </table>




<div id="openModal" class="modalDialog">
    <div>
        <a href="#" title="Close" class="close">X</a>
        <h2>Modal Box</h2>
    </div>
</div>

的index.php:

function popupwindow() {

            window.location="#openModal"
        }

0 个答案:

没有答案