正如您在下面看到的,我从数据库中提取信息并将其写入结构化格式的文本文件(感谢所有帮助我的人)。可能在mysql循环中循环“静态”数据
// Query the database for data
$query = "SELECT cards.card_id,title,description,meta_description,seo_keywords,price FROM cards,card_cheapest WHERE cards.card_id = card_cheapest.card_id ORDER BY card_id";
$result = mysql_query($query);
$result = mysql_query($query);
// Open file for writing
$myFile = "googleproducts.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
// Loop through returned data and write (append) directly to file
fprintf($fh, "%-10s %-50s %-450s %-50s %-300s\n", "id", "label","description","price","seo keywords");
fprintf($fh, "\n");
while ($row = mysql_fetch_assoc($result)) {
fprintf($fh, "%-10s %-50s %-450s %-50s %-300s\n", $row['card_id'], $row['title'], $row['description'],$row['price'], $row['seo_keywords']);
}
// Close out the file
fclose($fh);
?>
有一些事情需要添加到它不在数据库中的单独列中。主要只是一些文本,如“鲍勃的卡片”。我想知道是否有可能将它添加到混音中并让它循环播放。或者只是将它添加到数据库更简单?
你为什么'$结果= mysql_query($查询); $ result = mysql_query($ query);'连续查询数据库两次? – Johan 2011-05-19 14:26:16