单击以从数据库加载信息到jquery对话wordpress

I have a mySQL database table with events , artists, time , date, etc.

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
)

Then I have a page which lists these events through a query.

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>");


   }
?>

I have a jquery dialog set up to load more info for the selected event when clicked on.

<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>&nbsp;</td>
<td valign=top></td>
<td rowspan=2 valign=top>&nbsp;</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>");
}

How can I get the selected event ($artist_id) into the query (SELECT * FROM wp_artists WHERE artist_id = ????") from the click of a button(Artist Info) to populate the jquery dialog?

I have been on this for hours now and I think I'm getting to complicated with the solutions, I think it should be simple but I've tested a few things, i.e. making it a form, putting query's onto separate pages, etc.

All help will be greatly appreciated and thank you in advance.

doulu4534
doulu4534 嗨@thedarkcoder,刚才,如果我在sql查询中输入一个id号,然后单击艺术家底部的div按钮,对话框会显示所需的信息。但我需要它与我选择的艺术家有关。所以代替:SELECT*FROMwp_artistsWHEREartist_id=1我想要:SELECT*FROMwp_artistsWHEREartist_id='$artist_id'
接近 4 年之前 回复
dongqixian8474
dongqixian8474 是的,我点击了艺术家的更多信息按钮,出现了一个jquery对话框,其中包含数据库中的信息。
接近 4 年之前 回复
douchongzhang9267
douchongzhang9267 所以你有一个列表,你有艺术家的名字,点击任何名字,你想获取该艺术家的详细信息,是这样吗?
接近 4 年之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问