Помогите с PHP и MySQL
Суть скрипта следующая. Есть определенные типы товаров, которые занесены в массив. Надо подставлять эти типы в SQL запросы скрипта по очереди. Я новичок, поэтому может туплю. Подскажите пожалуйста как это реализовать!
$array = array(
"hdd",
"ssd",
"cooler",
);
$i=0;
while ($i <= count ($array)) {
echo "$query=\"SELECT pn,name,price,cena,picture,url,vendor,vend,names,pres,present,war,gar from `".array($i)."` left join `price1` on ".array($i).".pn=price1.code;\";
$result=mysql_query($query,$link);
while ($row=mysql_fetch_assoc($result)) {
$updateQuery=\"update ".array($i)." set pres='\".$row[\"present\"].\"' where pn='\".$row[\"pn\"].\"';\";
mysql_query($updateQuery,$link);
}
$query=\"SELECT pn,name,price,cena,picture,url,vendor,vend,names,pres,present,war,gar from `".array($i)."` left join `price1` on ".array($i).".pn=price1.code;\";
$result=mysql_query($query,$link);
while ($row=mysql_fetch_assoc($result)) {
$updateQuery=\"update ".array($i)." set picture='\".$row[\"url\"].\"' where pn='\".$row[\"pn\"].\"';\";
mysql_query($updateQuery,$link);
}
$query=\"SELECT pn,name,price,cena,picture,url,vendor,vend,names,pres,present,war,gar from `".array($i)."` left join `price1` on ".array($i).".pn=price1.code;\";
$result=mysql_query($query,$link);
while ($row=mysql_fetch_assoc($result)) {
$updateQuery=\"update ".array($i)." set vendor='\".$row[\"vend\"].\"' where pn='\".$row[\"pn\"].\"';\";
mysql_query($updateQuery,$link);
}
$query=\"SELECT pn,name,price,cena,picture,url,vendor,vend,names,pres,present,war,gar from `".array($i)."` left join `price1` on ".array($i).".pn=price1.code;\";
$result=mysql_query($query,$link);
while ($row=mysql_fetch_assoc($result)) {
$updateQuery=\"update ".array($i)." set name='\".$row[\"names\"].\"' where pn='\".$row[\"pn\"].\"';\";
mysql_query($updateQuery,$link);
}"
$i++;
}
for($i=0;$i<4;$i++){
echo "$query=\"SELECT pn,name,price,cena,picture,url,vendor,vend,names,pres,present,war,gar from `".$array[$i]."` left join `price1` on ".$array[$i].".pn=price1.code;\";
$result=mysql_query($query,$link);
while ($row=mysql_fetch_assoc($result)) {
$updateQuery=\"update ".$array[$i]." set pres='\".$row[\"present\"].\"' where pn='\".$row[\"pn\"].\"';\";
mysql_query($updateQuery,$link);
}
}4;$i++){
echo
Не сработало. Пишет
Parse error: syntax error, unexpected '[', expecting '(' in ...on line 18