No MySQL. I have used my databases and want to add a poll to my site. Is it possible? I should think so. But I'm not so sure how to start it. Would something like this work:
<html>
<head></head>
<body>
<form method="post" action="test.php">
<input type="radio" name="poll" value="one"> One
<br>
<input type="radio" name="poll" value="two"> Two<br>
<input type="submit" name="submit" value="Vote">
</form>
<?php
if ($one>$two) {
echo "$one is in the lead";
}
else if ($two>$one) {
echo "$two is in the lead";
}
?>
</body>
</html>
No that won't work, that could only show which is leading.
Plus it didn't work. You could get an image and stretch it to the variables right? Oh and I don't want a script I want to make one. This is for me to learn. And to enhance my site.if you don't want to use SQL (which is the best and fastest way) then you will have to use flat filesOk. I guess i could use mysql on my new host. But I don't know which functions i need and how it would displaya pecentage bar like most good polls.Possibly use PHP's mySQL_num_rows()
(think thats it) to *count* the rows/records.
Then display the # of each vote?
OR, additionly, do basicly the same
and use the GD Libery to 'dynamicly',
on-the-fly, create small images to use?all you need to know here;
<!-- m --><a class="postlink" href="http://www.alphibia.com/phpscripts.php?p=4That">http://www.alphibia.com/phpscripts.php?p=4That</a><!-- m --> was confusing. See I don't really get how mySQL works. Does it just store data?
<img src=http://www.htmlforums.com/archive/index.php/"grad1.png" width="<?php $1votes ?>"><br>
<img src=http://www.htmlforums.com/archive/index.php/"grad2.png" width-"<?php $2votes" ?>"><br>
What do you like better?<br>
<form action="poll.php">
<input type="radio" name="1">1<br>
<input type="radio" name="2">2<br>
<input type="submit" value="vote" name="vote">
</form>
<?php
if ($_POST[1]=true) {
f$=fopen("1votes.txt","a+");
fwrite($f,"I don't know what to do here, I want to add the number of votes inside the txt file with the one vote added");
fclose($f);
}
Then do the same for if the second one was voted
?>
there was lots wrong with that but do you get what I'm trying to do?Originally posted by Leonisknovo
Possibly use PHP's mySQL_num_rows()
(think thats it) to *count* the rows/records.
Sure is...
<?php
$sql = mysql_query("SELECT * FROM table");
$result = mysql_num_rows($sql);
print $result;
?>You may read about 'mysql' functions at <!-- m --><a class="postlink" href="http://www.php.net">http://www.php.net</a><!-- m -->
<html>
<head></head>
<body>
<form method="post" action="test.php">
<input type="radio" name="poll" value="one"> One
<br>
<input type="radio" name="poll" value="two"> Two<br>
<input type="submit" name="submit" value="Vote">
</form>
<?php
if ($one>$two) {
echo "$one is in the lead";
}
else if ($two>$one) {
echo "$two is in the lead";
}
?>
</body>
</html>
No that won't work, that could only show which is leading.
Plus it didn't work. You could get an image and stretch it to the variables right? Oh and I don't want a script I want to make one. This is for me to learn. And to enhance my site.if you don't want to use SQL (which is the best and fastest way) then you will have to use flat filesOk. I guess i could use mysql on my new host. But I don't know which functions i need and how it would displaya pecentage bar like most good polls.Possibly use PHP's mySQL_num_rows()
(think thats it) to *count* the rows/records.
Then display the # of each vote?
OR, additionly, do basicly the same
and use the GD Libery to 'dynamicly',
on-the-fly, create small images to use?all you need to know here;
<!-- m --><a class="postlink" href="http://www.alphibia.com/phpscripts.php?p=4That">http://www.alphibia.com/phpscripts.php?p=4That</a><!-- m --> was confusing. See I don't really get how mySQL works. Does it just store data?
<img src=http://www.htmlforums.com/archive/index.php/"grad1.png" width="<?php $1votes ?>"><br>
<img src=http://www.htmlforums.com/archive/index.php/"grad2.png" width-"<?php $2votes" ?>"><br>
What do you like better?<br>
<form action="poll.php">
<input type="radio" name="1">1<br>
<input type="radio" name="2">2<br>
<input type="submit" value="vote" name="vote">
</form>
<?php
if ($_POST[1]=true) {
f$=fopen("1votes.txt","a+");
fwrite($f,"I don't know what to do here, I want to add the number of votes inside the txt file with the one vote added");
fclose($f);
}
Then do the same for if the second one was voted
?>
there was lots wrong with that but do you get what I'm trying to do?Originally posted by Leonisknovo
Possibly use PHP's mySQL_num_rows()
(think thats it) to *count* the rows/records.
Sure is...
<?php
$sql = mysql_query("SELECT * FROM table");
$result = mysql_num_rows($sql);
print $result;
?>You may read about 'mysql' functions at <!-- m --><a class="postlink" href="http://www.php.net">http://www.php.net</a><!-- m -->