我有其他页面可以很好地更新数据,所以我认为这与我的内部连接有关。
这两个表是:medArt,行 idMed_med 设置为 primary,artistArt,idLogin_art 设置为 primary,idMed_art 设置为外键 两个表都是 INNODB
这是我的查询,整个代码都在它下面,因此您可以根据需要查看我是如何设置变量的。
SELECT artistArt.idLogin_art, artistArt.titleFirst_art,
artistArt.medFirst_art, artistArt.wFirst_art, artistArt.hFirst_art,
artistArt.pxFirst_art, artistArt.imageFirst_art, medArt.idMed_med,
medArt.nameMed_med
FROM artistArt, medArt
WHERE artistArt.idMed_art = medArt.idMed_med AND artistArt.idLogin_art = colname
代码:
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_connArt2013, $connArt2013);
$query_rsMedia = "SELECT * FROM medArt";
$rsMedia = mysql_query($query_rsMedia, $connArt2013) or die(mysql_error());
$row_rsMedia = mysql_fetch_assoc($rsMedia);
$totalRows_rsMedia = mysql_num_rows($rsMedia);
$colname_rsArtists = "1";
if (isset($_GET['idLogin_art'])) {
$colname_rsArtists = $_GET['idLogin_art'];
}
mysql_select_db($database_connArt2013, $connArt2013);
$query_rsArtists = sprintf("
SELECT artistArt.idLogin_art, artistArt.titleFirst_art, artistArt.medFirst_art,
artistArt.wFirst_art, artistArt.hFirst_art, artistArt.pxFirst_art,
artistArt.imageFirst_art, medArt.idMed_med, medArt.nameMed_med
FROM artistArt, medArt WHERE artistArt.idMed_art = medArt.idMed_med
AND artistArt.idLogin_art = %s", GetSQLValueString($colname_rsArtists, "int"));
$rsArtists = mysql_query($query_rsArtists, $connArt2013) or die(mysql_error());
$row_rsArtists = mysql_fetch_assoc($rsArtists);
$totalRows_rsArtists = mysql_num_rows($rsArtists);
?>