- 爱易网页
-
PHP教程
- 投票管理程序
日期:2013-01-06 浏览次数:20411 次
投票管理程序
表结构
CREATE TABLE poll(Poll_Id INT (11) not null AUTO_INCREMENT,Poll_Name char(50) ,Poll_Del INT (10) DEFAULT '0' , PRIMARY KEY (Poll_Id))
CREATE TABLE pollsele(Pollsele_Id INT (11) not null AUTO_INCREMENT,Pollsele_Name char(50) ,Poll_Del INT (10) DEFAULT '0' , Pollsele_poll_Id INT (10) ,pollsele_num int (10), PRIMARY KEY (Pollsele_Id))
-------------------------------------------------------------------------------------------------
poll.php //主程序
<? $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select poll_id,Poll_Name from poll where poll_del='1'";
@$result = mysql_query($sql);
$myrow=mysql_fetch_row($result);
echo "<table align=center bgcolor=aabbcc width=250 hight=450 border=0 style='border:1px solid rgb(0,0,0)'>";
echo "<td align=center bgcolor=99aabb style='border:1px solid rgb(255,255,255)'>";
echo "$myrow[1]";
$sql="select Pollsele_Name,pollsele_poll_id from pollsele where pollsele_del='0' and pollsele_poll_id='$myrow[0]'";
@$result = mysql_query($sql);
echo "<FORM ACTION='pollsee.php?poll_id=$myrow[0]' METHOD='post' target=_blank>";
echo "<p align=center>";
while($myrow=mysql_fetch_row($result))
{
echo "<input type='radio' name=toupiao value='$myrow[0]'>$myrow[0]";
echo " "; }
echo "<br>"; echo "<br>";
echo "<input type=submit name=submit value='投票' >";
echo "</p>";
echo "</form>"; echo "</td>";
echo "</table>";
mysql_close();
echo "<br>";
echo "<p align=right>";
echo "<a href=poll_input>管理</a>"; echo "</p>"; ?>
-----------------------------------------------------------------------
poll_input.php //添加主题
<? $db =mysql_connect("localhost", "root","391450");
mysql_select_db("class",$db);
$sql="select poll_id,poll_name,poll_del from poll";
echo "<table width=300 hight=560 bgcolor=aabbcc align=center style='border:1px solid rgb(0,0,0)'>";
$result=mysql_query($sql);
while($my=mysql_fetch_row($result))
{
echo "<tr>";echo "<td align=center width=50 bgcolor=99aabb style='border: 1px solid rgb(255,255,255)'>";echo $my[0];echo "</td>";
echo "<td align=center width=200 bgcolor=99aabb style='border: 1px solid rgb(255,255,255)'><a href
免责声明: 本文仅代表作者个人观点,与爱易网无关。其原创性以及文中陈述文字和内容未经本站证实,对本文以及其中全部或者部分内容、文字的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。