正如您在下面看到的,我從數據庫中提取信息並將其寫入結構化格式的文本文件(感謝所有幫助我的人)。可能在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