2016/4/29 問卷
<form action="#" method="post" class="demoForm" id="demoForm">
<fieldset>
<legend>Demo: Get Value of Selected</legend>
<p>Select a shipping method:</p>
<p>
<label><input type="radio" name="ship" value="a" checked /> a:Standard Ground</label>
<label><input type="radio" name="ship" value="b" /> b:Second Day</label>
<label><input type="radio" name="ship" value="c" /> c:Overnight</label>
<label><input type="radio" name="ship" value="d" /> d:Pick up</label>
</p>
<p><button type="button" name="getVal">Get Value of Selected</button></p>
</fieldset>
</form>
<script type="text/javascript">
// to remove from global namespace
(function() {
function getRadioVal(form, name) {
var val;
var radios = form.elements[name];
for (var i=0, len=radios.length; i<len; i++) {
if ( radios[i].checked ) {
val = radios[i].value;
break;
}
}
return val;
}
document.forms['demoForm'].elements['getVal'].onclick = function() {
alert( 'The selected radio button\'s value is: ' + getRadioVal(this.form, 'ship') );
};
// disable submission of all forms on this page
for (var i=0, len=document.forms.length; i<len; i++) {
document.forms[i].onsubmit = function() { return false; };
}
}());
</script>
2016年4月29日 星期五
2016年4月21日 星期四
1.下載阿帕契
2.進入xampp\htdocs\dashboard 創一個demo.php
3.
把php.ini檔 內已改為Big5
2.進入xampp\htdocs\dashboard 創一個demo.php
<?php
// 這是 C++ 風格註解
# 這是 Perl 風格註解
echo
"\n\n"
;
echo
date
(
"Y/m/d"
).
"\n"
;
echo
"↑↑ 上面印出今天幾月幾日\n"
;
echo
strftime
(
"%X"
,
time
()).
"\n"
;
echo
"↑↑ 上面印出現在幾點幾分\n"
;
echo
"\n\n"
;
/* 《程式語言教學誌》的範例程式
檔名:demo.php
功能:示範 PHP 程式
作者:張凱慶
時間:西元 2012 年 11 月 */
?>
http://pydoing.blogspot.tw/2012/11/php-Understanding-of-PHP-Progamming-Language.html
3.
把php.ini檔 內已改為Big5
2016年4月15日 星期五
安裝android 在 eclipse <------------------按照這個超連結做
軟體方面:你需要下載3樣東西
1. JAVA開發工具(Java Development kit - JDK)
2. Eclipse的JAVA開發環境(Eclipse IDE for Java Developers)
3. Android 開發工具(stand-alone Android SDK)
※ 各程式下載最新版即可
※ 有時候安裝不成功,不是你的問題,是程式的問題,請等官方解決
eclipse連接到mysql
http://blog.yslifes.com/archives/918 <-這個網址 按照步驟做
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class jdbcmysql {
private Connection con = null; //Database objects
//連接object
private Statement stat = null;
//執行,傳入之sql為完整字串
private ResultSet rs = null;
//結果集
private PreparedStatement pst = null;
//執行,傳入之sql為預儲之字申,需要傳入變數之位置
//先利用?來做標示
private String dropdbSQL = "DROP TABLE User ";
private String createdbSQL = "CREATE TABLE User (" +
" id INTEGER " +
" , name VARCHAR(20) " +
" , passwd VARCHAR(20))";
private String insertdbSQL = "insert into User(id,name,passwd) " +
"select ifNULL(max(id),0)+1,?,? FROM User";
private String selectSQL = "select * from User ";
public jdbcmysql()
{
try {
Class.forName("com.mysql.jdbc.Driver");
//註冊driver
con = DriverManager.getConnection(
"jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5",
"","");
//取得connection
//jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5
//localhost是主機名,test是database名
//useUnicode=true&characterEncoding=Big5使用的編碼
}
catch(ClassNotFoundException e)
{
System.out.println("DriverClassNotFound :"+e.toString());
}//有可能會產生sqlexception
catch(SQLException x) {
System.out.println("Exception :"+x.toString());
}
}
//建立table的方式
//可以看看Statement的使用方式
public void createTable()
{
try
{
stat = con.createStatement();
stat.executeUpdate(createdbSQL);
}
catch(SQLException e)
{
System.out.println("CreateDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//新增資料
//可以看看PrepareStatement的使用方式
public void insertTable( String name,String passwd)
{
try
{
pst = con.prepareStatement(insertdbSQL);
pst.setString(1, name);
pst.setString(2, passwd);
pst.executeUpdate();
}
catch(SQLException e)
{
System.out.println("InsertDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//刪除Table,
//跟建立table很像
public void dropTable()
{
try
{
stat = con.createStatement();
stat.executeUpdate(dropdbSQL);
}
catch(SQLException e)
{
System.out.println("DropDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//查詢資料
//可以看看回傳結果集及取得資料方式
public void SelectTable()
{
try
{
stat = con.createStatement();
rs = stat.executeQuery(selectSQL);
System.out.println("ID\t\tName\t\tPASSWORD");
while(rs.next())
{
System.out.println(rs.getInt("id")+"\t\t"+
rs.getString("name")+"\t\t"+rs.getString("passwd"));
}
}
catch(SQLException e)
{
System.out.println("DropDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//完整使用完資料庫後,記得要關閉所有Object
//否則在等待Timeout時,可能會有Connection poor的狀況
private void Close()
{
try
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(stat!=null)
{
stat.close();
stat = null;
}
if(pst!=null)
{
pst.close();
pst = null;
}
}
catch(SQLException e)
{
System.out.println("Close Exception :" + e.toString());
}
}
public static void main(String[] args)
{
//測看看是否正常
jdbcmysql test = new jdbcmysql();
test.dropTable();
test.createTable();
test.insertTable("yku", "12356");
test.insertTable("yku2", "7890");
test.SelectTable();
}
}
package db;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class jdbcmysql {
private Connection con = null; //Database objects
//連接object
private Statement stat = null;
//執行,傳入之sql為完整字串
private ResultSet rs = null;
//結果集
private PreparedStatement pst = null;
//執行,傳入之sql為預儲之字申,需要傳入變數之位置
//先利用?來做標示
private String dropdbSQL = "DROP TABLE User ";
private String createdbSQL = "CREATE TABLE User (" +
" id INTEGER " +
" , name VARCHAR(20) " +
" , passwd VARCHAR(20))";
private String insertdbSQL = "insert into User(id,name,passwd) " +
"select ifNULL(max(id),0)+1,?,? FROM User";
private String selectSQL = "select * from User ";
public jdbcmysql()
{
try {
Class.forName("com.mysql.jdbc.Driver");
//註冊driver
con = DriverManager.getConnection(
"jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5",
"","");
//取得connection
//jdbc:mysql://localhost/test?useUnicode=true&characterEncoding=Big5
//localhost是主機名,test是database名
//useUnicode=true&characterEncoding=Big5使用的編碼
}
catch(ClassNotFoundException e)
{
System.out.println("DriverClassNotFound :"+e.toString());
}//有可能會產生sqlexception
catch(SQLException x) {
System.out.println("Exception :"+x.toString());
}
}
//建立table的方式
//可以看看Statement的使用方式
public void createTable()
{
try
{
stat = con.createStatement();
stat.executeUpdate(createdbSQL);
}
catch(SQLException e)
{
System.out.println("CreateDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//新增資料
//可以看看PrepareStatement的使用方式
public void insertTable( String name,String passwd)
{
try
{
pst = con.prepareStatement(insertdbSQL);
pst.setString(1, name);
pst.setString(2, passwd);
pst.executeUpdate();
}
catch(SQLException e)
{
System.out.println("InsertDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//刪除Table,
//跟建立table很像
public void dropTable()
{
try
{
stat = con.createStatement();
stat.executeUpdate(dropdbSQL);
}
catch(SQLException e)
{
System.out.println("DropDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//查詢資料
//可以看看回傳結果集及取得資料方式
public void SelectTable()
{
try
{
stat = con.createStatement();
rs = stat.executeQuery(selectSQL);
System.out.println("ID\t\tName\t\tPASSWORD");
while(rs.next())
{
System.out.println(rs.getInt("id")+"\t\t"+
rs.getString("name")+"\t\t"+rs.getString("passwd"));
}
}
catch(SQLException e)
{
System.out.println("DropDB Exception :" + e.toString());
}
finally
{
Close();
}
}
//完整使用完資料庫後,記得要關閉所有Object
//否則在等待Timeout時,可能會有Connection poor的狀況
private void Close()
{
try
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(stat!=null)
{
stat.close();
stat = null;
}
if(pst!=null)
{
pst.close();
pst = null;
}
}
catch(SQLException e)
{
System.out.println("Close Exception :" + e.toString());
}
}
public static void main(String[] args)
{
//測看看是否正常
jdbcmysql test = new jdbcmysql();
test.dropTable();
test.createTable();
test.insertTable("yku", "12356");
test.insertTable("yku2", "7890");
test.SelectTable();
}
}
訂閱:
文章 (Atom)