我有一个mySQL数据库表,包含事件,艺术家,时间,日期等。
CREATE TABLE IF NOT EXISTS `wp_artists` (
`artist_id` int(10) NOT NULL,
`artist_name` varchar(255) NOT NULL,
`artist_info` varchar(1000) NOT NULL,
`date` varchar(35) NOT NULL,
`time` varchar(10) NOT NULL,
`venue` varchar(100) NOT NULL,
`pic` varchar(100) NOT NULL,
`video` varchar(200) NOT NULL,
`book_url` varchar(100) NOT NULL
)
然后我有一个页面,通过查询列出这些事件。
global $wpdb;
$results = $wpdb->get_results("SELECT * FROM wp_artists", ARRAY_A);
foreach($results as $row) {
$artist_id = $row['artist_id'];
$artist_name = $row['artist_name'];
$artist_info = $row['artist_info'];
$date = $row['date'];
$time = $row['time'];
$venue = $row['venue'];
$pic = $row['pic'];
$fee = $row['fee'];
print ("<div class=event_float>");
print ("<div class=event>".$date."</div><img class=aligncenter size-full wp-image-1652 src=".$pic." />
<h4> ".$time." </h4><h2>".$artist_name."</h2><strong>".$venue."</strong><i>".$fee."</i><a href=".$book_url." target=_blank><img src=http:# alt=book now width=64 height=22 /></a>
<div class=infoEvent><h4>Artist Info</h4></div></div>");
}
?>
我设置了一个jquery对话框,以便在单击时为所选事件加载更多信息。
<script>
$( function() {
$( "#blu" ).dialog({
autoOpen: false,
width: 925,
height: 800,
modal: true,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});
$( ".infoEvent" ).on( "click", function() {
$( "#blu" ).dialog('open');
});
} );
</script>
<?php
global $wpdb;
$myData = $wpdb->get_results($wpdb->prepare("SELECT * FROM wp_artists WHERE artist_id = ????", ARRAY_A));
foreach($myData as $row){
$artist_id = $row->artist_id;
$artist_name = $row->artist_name;
$info = $row->artist_info;
$venue = $row->venue;
$date = $row->date;
$time = $row->time;
$pic = $row->pic;
$video = $row->video;
$book_url = $row->book_url;
print ("<div id=blu style=background-color: #ff0000");//url(".$pic.") top no-repeat>
print ("<table border=0 class=table>");
print ("<tr><td colspan=5 valign=top><h3>".$artist_name."</h3><br><b>".$date."</b> ".$time." <h4>".$venue."</h4></td>
</tr>
<tr>
<td rowspan=2 valign=top><div class=tryer><img class=aligncenter size-full wp-image-1676 src=".$pic." /></div><br><div class=tryer2><iframe width=320 height=115 src=".$video."frameborder=0 allowfullscreen></iframe></div></td>
<td rowspan=2 valign=top> </td>
<td valign=top></td>
<td rowspan=2 valign=top> </td>
<td rowspan=2 valign=top></div></td>
</tr>
<tr>
<td valign=top><div class=boxer><p>".$info."</p></div><br><div class=tryer3> <a href=".$book_url." target=_blank><img src=http:# alt=book now width=64 height=22 /></a>
</div></td>
</tr>
</table>");
print ("</div>");
}
如何通过单击按钮(艺术家信息)将所选事件($ artist_id)放入查询(SELECT * FROM wp_artists WHERE artist_id = ????“)以填充jquery对话框?
我已经在这几个小时了,我想我已经开始复杂化了解决方案,我认为它应该很简单,但我已经测试了一些东西,即将它作为一个表单,将查询放在单独的页面上等等。
非常感谢所有帮助,并提前感谢您。