我已经为此工作了两天,阅读了所有内容,但我无法得到答案。提前谢谢你看这个!!!
我有一个加入几个表的查询,它输出我正在寻找的内容这是我的选择
mysql_select_db($database_dbConnect, $dbConnect);
$query_rsMale = "SELECT r.points, r.license, l.acaNo, l.firstName, l.lastName,
l.cxage, l.cxcat,l.cxteam, l.city, l.state, l.gender FROM rankingsM r INNER
JOIN field f ON r.license=f.USAC_No INNER JOIN racers l ON l.usacNo=f.USAC_No
ORDER BY points";
$rsMale = mysql_query($query_rsMale, $dbConnect) or die(mysql_error());
$row_rsMale = mysql_fetch_assoc($rsMale);
$totalRows_rsMale = mysql_num_rows($rsMale);
echo "<br> This is num " . $totalRows_rsMale . "<br>";
我已将其下载到其他页面上的 csv 文件中,并且工作正常。然后我把那个数组放入另一个带有内爆的数组中。
$newData = implode(",",$row_rsMale );
$newData = mysql_real_escape_string($newData);
echo "<br> This is newdata <br>". $newData;
这是我得到 Column not matching 错误的地方。我检查了它们匹配的列,我检查了数据类型,它们匹配。
$insertSQL ="INSERT INTO ranking (points, usacNo, acaNo, firstName, lastName,
cxage, cxcat, cxteam, city, state, gender)
SELECT ( '$newData' )";
$Result1 = mysql_query($insertSQL, $dbConnect) or die(mysql_error());
echo "<br>Insert complete!<br>";
接下来我做了列的显示
$rankingSQL ="Select * from ranking";
$result = mysql_query($rankingSQL, $dbConnect) or die(mysql_error());
echo "<table><tr>";
for($i = 0; $i < mysql_num_fields($result); $i++) {
$field_info = mysql_fetch_field($result, $i);
echo "<th>{$field_info->name},</th>";
}
这是我网站上我的页面上显示的内容 这是插入之前 这是数字 22
这是新数据 185.34,362355,4174,Shawn,Lortie,47,2,Rally Sport Cycling Team,BOULDER,CO,M points, usacNo, acaNo, firstName, lastName, cxage, cxcat, cxteam, city, state, gender, (为了便于阅读,我在列上添加了逗号。)列数与第 1 行的值计数不匹配
我最终回到了`while ($l = mysql_fetch_array($result)) {
{
$insertSQL = sprintf("INSERT INTO ranking (points, usacNo, acaNo, firstName,
lastName, cxage, cxcat, cxteam, city, `state`, gender) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)",
GetSQLValueString($l ['points'], "double"),
GetSQLValueString($l ['license'], "int"),
GetSQLValueString($l ['acaNo'], "int"),
GetSQLValueString($l ['firstName'], "text"),
GetSQLValueString($l ['lastName'], "text"),
GetSQLValueString($l ['cxage'], "int"),
GetSQLValueString($l ['cxcat'], "int"),
GetSQLValueString($l ['cxteam'], "text"),
GetSQLValueString($l ['city'], "text"),
GetSQLValueString($l ['state'], "text"),
GetSQLValueString($l ['gender'], "text"));
$Result1 = mysql_query($insertSQL, $dbConnect) or die("<br>Error is " . mysql_error());
}`