Arkadaşlar İyi Günler Dreamweaver'da Anket Yapmam Lazım 3 veya 4 sorulu sonuçları txt dosyasına kaydetmesi lazım. Bir türlü beceremedim SOn çare olarak konu açtım Final notu yerine geçecek Yardımcı olurmusunuz lütfen. Teşekkürler.
crimsonica
kullanıcısına yanıt
İndex.php
<?php /************************************************* * Micro Polling System * * Version: 1.0 * Date: 2007-04-05 * * Usage: * Add your votings settings to polldata.txt file * The first line is the question and the other * linas are the possible answers. * ****************************************************/
$pollQuestion = ''; $answers = '';
function readData(){ global $pollQuestion,$answers; // Read configuration $rawdata = file('polldata.txt'); // Get the question for polling $pollQuestion = $rawdata[0];
// Get number of answers - The foirs row is the question $numberOfAnswers = sizeof($rawdata)-1; $count = 0; for ($i=1; $i <= $numberOfAnswers; $i++){ $answerData = explode(':',$rawdata[$i]); // If tha actual row is not empty than add to the answers array if (strlen(trim($answerData[0]))>0){ $answers[$count]['text'] = $answerData[0]; $answers[$count]['count'] = $answerData[1]; ++$count; } } }
function writeData(){ global $pollQuestion,$answers; $file = fopen('polldata.txt','w'); fwrite($file,$pollQuestion."\r\n",strlen($pollQuestion)); foreach ($answers as $value) { $row = $value['text'].':'.$value['count']."\r\n"; fwrite($file,$row,strlen($row)); } fclose($file); }