(1)_
vote.jsp
<SCRIPT LANGUAGE="JavaScript"><!--
function poll(){
return document.getElementById('poll').submit();
}
//-->
</SCRIPT>
<sql:query var="rs" dataSource="${dataSource}" maxRows="1">
select * from tb_vote order by createdDate desc
</sql:query>
<c:set var="vote" value="${rs.rows[0]}"/>
<sql:query var="rs" dataSource="${dataSource}">
select * from tb_voteitem where vote_id = ?
<sql:param value="${vote.id}"/>
</sql:query>
<center>${vote.subject}</center>
<FORM id="poll" action="poll.jsp" METHOD="post" target="_blank">
<input type="hidden" name="vote.id" value="${vote.id}"/>
<c:forEach var="voteitem" items="${rs.rows}">
<INPUT TYPE="radio" NAME="voteitem.id" VALUE="${voteitem.id}">${voteitem.title}<BR>
</c:forEach>
<INPUT TYPE="button" onClick="return poll();" VALUE="提交" style=" float:RIGHT">
</FORM>
(2)
poll.jsp
<SCRIPT LANGUAGE="JavaScript">
<!--
function init(){
window.resizeTo(400, 400);
alert("感谢您的支持");
}
//-->
</SCRIPT>
<sql:update var="vote" dataSource="${dataSource}" >
update tb_voteitem set count = count + 1 where id = ?
<sql:param value="${param['voteitem.id']}"/>
</sql:update>
<sql:update var="vote" dataSource="${dataSource}" >
update tb_vote set count = count + 1 where id = ?
<sql:param value="${param['vote.id']}"/>
</sql:update>
<sql:query var="rs" dataSource="${dataSource}" maxRows="1">
select * from tb_vote order by createdDate desc
</sql:query>
<c:set var="vote" value="${rs.rows[0]}"/>
<sql:query var="rs" dataSource="${dataSource}">
select * from tb_voteitem where vote_id = ?
<sql:param value="${vote.id}"/>
</sql:query>
<body onLoad="init();">
${vote.subject} 共${vote.count}票
<FORM ACTION="vote_compute.jsp" METHOD="post">
<table>
<c:forEach var="voteitem" items="${rs.rows}">
<tr>
<th>${voteitem.title}</th>
<td><img src="res/poll_bg.gif" height="20px" width="${voteitem.count/vote.count*200}"></td>
<td>${voteitem.count}</td>
</tr>
</c:forEach>
</table>
</body>
(3)
createVote!input.jsp
<FORM METHOD=POST ACTION="createVoteAction.jsp" onSubmit="return check();">
<TABLE class="inputTable">
<TR><Th>主题</Th><TD><INPUT TYPE="text" NAME="subject" size="60"></TD></TR>
<TR><Th>开始日期</Th><TD><INPUT TYPE="text" NAME="createdDate"></TD></TR>
<TR><Th> </Th><TD><INPUT TYPE="submit" value="提 交"></TD></TR>
</TABLE>
</FORM>
(4)
createVoteAction.jsp
<sql:update var="rs" dataSource="${dataSource}" >
insert into tb_vote(subject,count,createdDate) values(?,?,?)
<sql:param value="${param['subject']}"/>
<sql:param value="0"/>
<sql:param value="<%=new java.util.Date()%>"/>
</sql:update>
<c:redirect url="listVote.jsp"/>
(5)
editVote!input.jsp
<sql:query var="rs" dataSource="${dataSource}" >
select * from tb_vote where id = ?
<sql:param value="${param['id']}"/>
</sql:query>
<c:set var="vote" value="${rs.rows[0]}"/>
<FORM METHOD=POST ACTION="editVoteAction.jsp" >
<INPUT TYPE="hidden" NAME="id" value="${vote.id}">
<TABLE class="inputTable">
<TR><Th>标题</Th><TD><INPUT TYPE="text" NAME="subject" value="${vote.subject}" size="60" ></TD></TR>
<TR><Th>总票数</Th><TD>
<INPUT TYPE="text" NAME="count" value="${vote.count}")"></TD></TR>
<TR><Th>开始日期</Th><TD><INPUT TYPE="text" NAME="time" value="${vote.createdDate}"></TD></TR>
<TR><Th></Th><TD><INPUT TYPE="submit" value="提交"> <INPUT Type="reset" value="重置"></TD></TR>
</TABLE>
</FORM>
(6)
editVoteAction.jsp
<sql:update var="vote" dataSource="${dataSource}" >
update tb_vote set subject = ?,count = ?,createdDate=? where id = ?
<sql:param value="${param['subject']}"/>
<sql:param value="${param['count']}"/>
<sql:param value="${param['id']}"/>
<c:choose>
<c:when test="${empty(param['createdDate'])}">
<sql:param value="<%=new java.sql.Timestamp(System.currentTimeMillis())%>" />
</c:when>
<c:otherwise>
<sql:param value="${param['createdDate']}" />
</c:otherwise>
</c:choose>
</sql:update>
<c:redirect url="listVote.jsp"/>
(7)
deleteVote.sjp
<sql:update var="rs" dataSource="${dataSource}" >
delete from tb_vote where id = ?
<sql:param value="${param['id']}"/>
</sql:update>
<c:redirect url="listVote.jsp"/>
<!#$#$!$#$!#$#$#^%^%^%^*&^*&*&*()(*)()_)+_%&$>
(8)_
CreateVoteItem.jsp
<FORM METHOD=POST ACTION="createVoteItemAction.jsp" onSubmit="return check();">
<TABLE class="inputTable">
<INPUT TYPE="hidden" NAME="vote.id" value="${param['vote.id']}"></TD></TR>
<TR><Th>选项</Th><TD><INPUT TYPE="text" NAME="title"></TD></TR>
<TR><Th>记票</Th><TD><INPUT TYPE="text" NAME="count"></TD></TR>
<TR><Th> </Th><TD><INPUT TYPE="submit" value="提 交"></TD></TR>
</TABLE>
</FORM>
(9)
createVoteItemAction.jsp
<sql:update var="rs" dataSource="${dataSource}" >
insert into tb_voteitem(vote_id,title,count) values(?,?,?) <!--
tb_voteItem . vote_id= tb_vote.id >级联
<sql:param value="${param['vote.id']}"/>
<sql:param value="${param['title']}"/>
<sql:param value="0"/>
</sql:update>
(10)
listVoteItem.jsp
<a href="createVoteItem!input.jsp?vote.id=${param['vote.id']}">添加</a>
<sql:query var="rs" dataSource="${dataSource}" >
select * from tb_voteitem where vote_id = ?
<sql:param value="${param['vote.id']}"/>
</sql:query>
<div>
<form action="listVoteItem.jsp" method="POST">
<table class="listTable">
<tr>
<th width="50%">标题</th>
<th width="10%">票数</th>
<th width="3%"> </th>
<th width="3%"> </th>
</tr>
<c:forEach var="voteitem" items="${rs.rows}">
<tr>
<td>${voteitem.title}</td>
<td>${voteitem.count}</td>
<td><a href="editVoteItem!input.jsp?id=${voteitem.id}" title="编辑该记录">编辑</a></td>
<td><a href="javascript:if(confirm('您确认删除吗?')){document.location.href='deleteVoteItemAction.jsp?id=${voteitem.id}&vote.id=${voteitem.vote_id}'};">删除</a></td>
</tr>
</c:forEach>
</table>
</form>
(10)
editVoteItem!input.jsp
<sql:query var="rs" dataSource="${dataSource}" >
select * from tb_voteitem where id = ?
<sql:param value="${param['id']}"/>
</sql:query>
<c:set var="voteitem" value="${rs.rows[0]}"/>
<FORM METHOD=POST ACTION="editVoteItemAction.jsp" >
<INPUT TYPE="hidden" NAME="id" value="${voteitem.id}">
<TABLE class="inputTable">
<INPUT TYPE="hidden" NAME="vote.id" value="${voteitem.vote_id}")">
<TR><Th>title</Th><TD><INPUT TYPE="text" NAME="title" value="${voteitem.title}")"></TD></TR>
<TR><Th>count</Th><TD>
<INPUT TYPE="text" NAME="count" value="${voteitem.count}")"></TD></TR>
<TR><Th></Th><TD><INPUT TYPE="submit" value="提交"> <INPUT Type="reset" value="重置"></TD></TR>
</TABLE>
</FORM>
(11)
editVoteItemAction.jsp
<sql:update var="rs" dataSource="${dataSource}" >
update tb_voteItem set title = ? count=? where id = ?
<sql:param value="${param['title']}"/>
<sql:param value="${param['count']}"/>
<sql:param value="${param['id']}"/>
</sql:update>
<c:redirect url="listVoteItem.jsp?vote.id=${param['vote.id ']}"/>
(11)mysql 导出数据 http://fanqiang.chinaunix.net/db/mysql/2001-05-27/1357.shtml
mysqldump -d -u Username -p address_ip >;c:\test.txt
我来写详细一些,这样可以只导出表结构,主要是-d参数,不会导出数据。
1.导出整个数据库
mysqldump -u 用户名 -p 数据库名 > 导出的文件名
mysqldump -u wcnc -p smgp_apps_wcnc > wcnc.sql
2.导出一个表
mysqldump -u 用户名 -p 数据库名 表名> 导出的文件名
mysqldump -u wcnc -p smgp_apps_wcnc users> wcnc_users.sql
3.导出一个数据库结构
mysqldump -u wcnc -p -d --add-drop-table smgp_apps_wcnc >d:wcnc_db.sql
-d 没有数据 --add-drop-table 在每个create语句之前增加一个drop table
4.导入数据库
常用source 命令
进入mysql数据库控制台,
如mysql -u root -p
mysql>use 数据库
然后使用source命令,后面参数为脚本文件(如这里用到的.sql)
mysql>source d:wcnc_db.sql