我當前有一個由sql查詢生成的表。該頁面的網址是http://skunkboxstudios.com/dev/ofa-courses/從SQL動態生成的表中獲取單個值並在Wordpress的另一個表中使用它
在表中,每行上都有一個按鈕,顯示一個模式窗口,該窗口顯示所在行的更多詳細信息。我如何告訴模態窗口只選擇關於它所在行的信息。
這裏是頁表的代碼:
global $wpdb;
$courses = $wpdb->get_results("SELECT * FROM section_view;");
$results = array();
echo "<table>";
echo "<tr>";
echo "<th>Section Name</th>";
echo "<th>Section Description</th>";
echo "<th>Start Date</th>";
echo "<th>End Date</th>";
echo "<th>Location</th>";
echo "<th>Details</th>";
echo "</tr>";
foreach($courses as $course){
$sectionname = "$course->section_name";
$sectiondescription = "$course->section_description";
$sectionstartdate = "$course->term_startdate";
$sectionenddate = "$course->term_enddate";
$sectionlocation= "$course->location_name";
$sectionid = "$course->section_id";
echo "<tr>";
echo "<td>$sectionname</td>";
echo "<td>$sectiondescription</td>";
echo "<td>$sectionstartdate</td>";
echo "<td>$sectionenddate</td>";
echo "<td>$sectionlocation</td>";
echo "<td>$sectionid</td>";
echo "<td>";
echo "<button class='element' onclick='javascript:openDialog();'>Details</button>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
的模態窗口的代碼是在這裏:
$details = $wpdb->get_results(
"SELECT * FROM section_view WHERE section_id = '$sectionid';");
foreach($details as $detail){
echo "<h2>".$detail->section_name."</h2>";
echo "<table>";
echo "<tr>";
echo "<td>".$detail->section_name."</td>";
echo "<td>".$detail->section_description."</td>";
echo "</tr>";
echo "</table>";
}
echo "<button class='element' onclick='javascript:closeDialog();'>Close</button>";
所以我需要在模式窗口的查詢SELECT * FROM section_view WHERE section_id ='section_id對應於其所在行的表格'
如果有人可以幫助我,請做。如果您需要,我會發布更多信息。謝謝。
我把我的網址放在我的openDialog調用中,就像你建議的那樣,但它打破了它,模態窗口不會再打開。我是否需要將該網址放入JavaScript模式窗口中?我很抱歉,我應該把它放在這裏。這裏是: '' – Pierce