我有一個值的列表,在超鏈接'onclick'將在下面的數組中顯示關聯的記錄集。php onclick檢索數據集
通過PHP,我有連接表值工作的數據集。現在我需要將該數據集鏈接到onclick事件。
通過我的研究,我可以做幾件事:iFrames(似乎不推薦); JSON/AJAX(我不知道的語言以及我的其他數據都沒有使用這種構造,但可以使用直接PHP嗎?);
$ _GET變量與相關函數似乎是要走的路雖然我努力獲得正確的語法來創建一個響應。這是否會使用過濾器功能?
本質上:$ row_artistrecordset ['artist'] = $ row_getartists ['artist']。如果我可以將代碼基於這個匹配結構,它將有望在其他頁面中使用。
這是我到目前爲止的代碼:
<?php
mysql_select_db($database_connectmysql, $connectmysql);
$query_artistrecordset = "SELECT * FROM artists ORDER BY artist ASC";
$artistrecordset = mysql_query($query_artistrecordset, $connectmysql) or die(mysql_error());
$row_artistrecordset = mysql_fetch_assoc($artistrecordset);
$totalRows_artistrecordset = mysql_num_rows($artistrecordset);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>artistindex</title>
<link href="exhibitstyles/exhibitstyles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php include_once("exhibitstyles/header.php");?>
<div id="singlemid" class="paragraph" style="text-align:center">
<div id="artistlist">
<?php do { ?>
<a href=javascript:function_$_GET(artistindex.php?[$row_artistrecordset['artist']]);>; title="artistlink" class="list"><?php echo $row_artistrecordset['artist']; ?></a> |
<?php } while ($row_artistrecordset = mysql_fetch_assoc($artistrecordset)); ?>
</div>
<br />
<div id="searchresults">
function_$_GET(artistindex.php?[$row_artistrecordset['artist']]) {
$.post("artistindex.php",'v=.$row_getartists['artist'].' + value, function $_GET(artistindex.php?[$row_artistrecordset['artist']]) {
$query_getartists.html().trigger("create");
});
}
<?php
mysql_select_db($database_connectmysql, $connectmysql);
echo <a href=javascript:function_$_GET(artistindex.php?[$row_artistrecordset['artist']]);>.$row_getartists['artist'].;
$query_getartists = "SELECT * FROM artists WHERE artist = '".$row_artistrecordset['artist']."' ORDER BY artist ASC";
$getartists = mysql_query($query_getartists, $connectmysql) or die(mysql_error());
while ($row_getartists = mysql_fetch_assoc($getartists)) {
echo $row_getartists['artist'], "<br>";
echo $row_getartists['website'], "<br>";
echo $row_getartists['artist_statement'], "<br>";
echo $row_getartists['image'], "<br>";
$artistlink = $row_getartists['artist'];
$query_getseries = "SELECT * FROM series WHERE artist='$artistlink' ORDER BY exhibition ASC";
$getseries = mysql_query($query_getseries, $connectmysql) or die(mysql_error());
while ($row_getseries = mysql_fetch_assoc($getseries)) {
echo $row_getseries['series'], "<br>";
echo $row_getseries['exhibition'], "<br>";
echo $row_getseries['series_statement'], "<br>";
echo $row_getseries['image'], "<br>";
$serieslink = $row_getseries['series'];
$query_getpieces = "SELECT * FROM pieces WHERE series='$serieslink'";
$getpieces = mysql_query($query_getpieces, $connectmysql) or die(mysql_error());
while ($row_getpieces = mysql_fetch_assoc($getpieces)) {
echo $row_getpieces['piece'], "<br>";
echo $row_getpieces['category'], "<br>";
echo $row_getpieces['dimensions'], "<br>";
echo $row_getpieces['price'], "<br>";
echo $row_getpieces['description'], "<br>";
echo $row_getpieces['image'], "<br>";
}
}
?>
</div>
</div>
</body>
</html>
<?php
mysql_free_result($getartists);
mysql_free_result($getseries);
mysql_free_result($getpieces);
}
?>
如果我這樣做完全錯了,請告訴我。我發現試圖實現類似目標的其他問題也沒有得到回答,因此很難知道這個邏輯有什麼問題。 – sarah369
「onclick」定義了一個在單擊元素時將執行的Javascript函數。要做一些比如你想要的事情,需要改變爲另一個PHP腳本,它將生成新的頁面,或者更好的AJAX調用,它將刷新頁面上的數據而不重新加載它。查看jQuery,以真正簡單的方式使用AJAX。 – mlewis54
對!所以我做錯了,不知情地使用js ......謝謝!這是我需要知道的! – sarah369