本站於2009年10月28日成立,本人將盡力提供好的資訊,希望對大家會有幫助。也希望大家可以幫忙點一下廣告,謝謝大家。
版權所有,引用請註明引用來源,謝謝光臨。 部份文章來源為網路上,如有侵權,請留言,我會馬上刪除,謝謝。
- Oct 14 Fri 2016 13:58
-
PHP curl 判斷有效連結
- Oct 14 Wed 2015 20:39
-
sublime安裝
- Oct 14 Wed 2015 20:21
-
PHP教學(二)MySQL資料庫設定

xampp解壓縮執行後, http://localhost 可以看到xampp的畫面,可以再輸入 http://localhost/phpmyadmin 進入資料庫管理網頁。
剛開始xampp資料庫沒有密碼, 請注意畫面下方紅字部份,我們要自行設定密碼, 請到上面按「權限」,點「使用候:root」〔 王機:localhost」的右邊圖形。
- Oct 14 Wed 2015 20:09
-
PHP教學(一)伺服器安裝

PHP需要安裝Apache伺服器,並把php檔案存在Apache內的「www」或「htdocs」資料夾內,才可以執行。
Apache伺服器可以用xampp或Appserv安裝,xampplite為免安裝伺服器,解壓縮後,執行xampp_start,即可以使用。
- Mar 29 Thu 2012 09:38
-
Synology NAS的cron排程
程式碼:存成網頁cronjobs.php
<?php
if ($_REQUEST['action'] == 'save') {
$out='';
for($r=1;$r<=$_REQUEST['rows'];++$r)
if ($_REQUEST['r'.$r.'c0']!='') for($c=0;$c<7;++$c) $out.=$_REQUEST['r'.$r.'c'.$c].($c<6?chr(9):chr(10));
file_put_contents('/etc/crontab', $out);
exec('killall crond;crond');
}
$filearray=file('/etc/crontab');
$_REQUEST['action'] == '';
?>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>cronjobs</title>
<style>body,input{font:12px Arial;margin-right:1px;margin-bottom:1px}h3{font-family:Arial}
body{background-color:#ddf}</style>
<script>
function mark(r) {
var e=document.getElementsByName(r+'c0')[0];
if (e.value.charAt(0)=='#')
for (var i=0;i<7;++i) document.getElementsByName(r+'c'+i)[0].style.color='#444';
else
for (var i=0;i<7;++i) document.getElementsByName(r+'c'+i)[0].style.color='#090';
}
</script>
</head><body><h3>CronJobs</h3>
<form method="post" action="cronjobs.php">
<input type="hidden" id="action" name="action" value="">
<?php
$r=0;
foreach($filearray as $rec) {
$r++; $c=0;$f=explode(chr(9),$rec);
print '<input title="*|0..59: 8 1,3,5 2-5 * */2" name="r'.$r.'c0" type="text" size="8" '.($r==1?'readonly':'').' value="'.$f[0].'"/>';
print '<input title="*|0..23: 8 1,3,5 2-5 * */2" name="r'.$r.'c1" type="text" size="7" '.($r==1?'readonly':'').' value="'.$f[1].'"/>';
print '<input title="*|1..31: 8 1,3,5 2-5 * */2" name="r'.$r.'c2" type="text" size="7" '.($r==1?'readonly':'').' value="'.$f[2].'"/>';
print '<input title="*|1..12: 8 1,3,5 2-5 * */2" name="r'.$r.'c3" type="text" size="7" '.($r==1?'readonly':'').' value="'.$f[3].'"/>';
print '<input title="*|0..7: so=0/7 sa=6" name="r'.$r.'c4" type="text" size="7" '.($r==1?'readonly':'').' value="'.$f[4].'"/>';
print '<input name="r'.$r.'c5" type="text" size="7" '.($r==1?'readonly':'').' value="'.$f[5].'"/>';
print '<input name="r'.$r.'c6" type="text" size="40" '.($r==1?'readonly':'').' value="'.$f[6].'"/>';
if ($r>1) {
print '<script>mark("r'.$r.'")</script>';
?>
<input type="button" value="X" title="delete"
onclick="for (var i=0;i<7;++i) document.getElementsByName('r<?php print $r ?>c'+i)[0].value=''"/>
<input type="button" value="#" title="activate / deactivate"
onclick="var v=document.getElementsByName('r<?php print $r ?>c0')[0];
if (v.value.charAt(0)!='#') v.value='#'+v.value;else v.value=v.value.substring(1); mark('r<?php print $r ?>')"/>
<?php }
print '<br/>';
}
$rmax=2+$r++;
for($r;$r<=$rmax;$r++) {
print '<input title="*|0..59: 8 1,3,5 2-5 * */2" name="r'.$r.'c0" type="text" size="8" value=""/>';
print '<input title="*|0..23: 8 1,3,5 2-5 * */2" name="r'.$r.'c1" type="text" size="7" value=""/>';
print '<input title="*|1..31: 8 1,3,5 2-5 * */2" name="r'.$r.'c2" type="text" size="7" value=""/>';
print '<input title="*|1..12: 8 1,3,5 2-5 * */2" name="r'.$r.'c3" type="text" size="7" value=""/>';
print '<input title="*|0..7: so=0/7 sa=6" name="r'.$r.'c4" type="text" size="7" value=""/>';
print '<input name="r'.$r.'c5" type="text" size="7" value=""/>';
print '<input name="r'.$r.'c6" type="text" size="40" value=""/>';
?>
<input type="button" value="X" title="delete"
onclick="for (var i=0;i<7;++i) document.getElementsByName('r<?php print $r ?>c'+i)[0].value=''"/>
<input type="button" value="#" title="activate / deactivate"
onclick="var v=document.getElementsByName('r<?php print $r ?>c0')[0];
if (v.value.charAt(0)!='#') v.value='#'+v.value;else v.value=v.value.substring(1); mark('r<?php print $r ?>')"/><br/>
<?php } ?>
<input type="hidden" name="rows" value="<?php print --$r ?>"/>
<input type="button" value="save /etc/crontab & restart crond" style="margin-top:6px"
onclick="document.getElementById('action').value='save';submit()"/>
</form></body></html>
<?php
if ($_REQUEST['action'] == 'save') {
$out='';
for($r=1;$r<=$_REQUEST['rows'];++$r)
if ($_REQUEST['r'.$r.'c0']!='') for($c=0;$c<7;++$c) $out.=$_REQUEST['r'.$r.'c'.$c].($c<6?chr(9):chr(10));
file_put_contents('/etc/crontab', $out);
exec('killall crond;crond');
}
$filearray=file('/etc/crontab');
$_REQUEST['action'] == '';
?>
<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>cronjobs</title>
<style>body,input{font:12px Arial;margin-right:1px;margin-bottom:1px}h3{font-family:Arial}
body{background-color:#ddf}</style>
<script>
function mark(r) {
var e=document.getElementsByName(r+'c0')[0];
if (e.value.charAt(0)=='#')
for (var i=0;i<7;++i) document.getElementsByName(r+'c'+i)[0].style.color='#444';
else
for (var i=0;i<7;++i) document.getElementsByName(r+'c'+i)[0].style.color='#090';
}
</script>
</head><body><h3>CronJobs</h3>
<form method="post" action="cronjobs.php">
<input type="hidden" id="action" name="action" value="">
<?php
$r=0;
foreach($filearray as $rec) {
$r++; $c=0;$f=explode(chr(9),$rec);
print '<input title="*|0..59: 8 1,3,5 2-5 * */2" name="r'.$r.'c0" type="text" size="8" '.($r==1?'readonly':'').' value="'.$f[0].'"/>';
print '<input title="*|0..23: 8 1,3,5 2-5 * */2" name="r'.$r.'c1" type="text" size="7" '.($r==1?'readonly':'').' value="'.$f[1].'"/>';
print '<input title="*|1..31: 8 1,3,5 2-5 * */2" name="r'.$r.'c2" type="text" size="7" '.($r==1?'readonly':'').' value="'.$f[2].'"/>';
print '<input title="*|1..12: 8 1,3,5 2-5 * */2" name="r'.$r.'c3" type="text" size="7" '.($r==1?'readonly':'').' value="'.$f[3].'"/>';
print '<input title="*|0..7: so=0/7 sa=6" name="r'.$r.'c4" type="text" size="7" '.($r==1?'readonly':'').' value="'.$f[4].'"/>';
print '<input name="r'.$r.'c5" type="text" size="7" '.($r==1?'readonly':'').' value="'.$f[5].'"/>';
print '<input name="r'.$r.'c6" type="text" size="40" '.($r==1?'readonly':'').' value="'.$f[6].'"/>';
if ($r>1) {
print '<script>mark("r'.$r.'")</script>';
?>
<input type="button" value="X" title="delete"
onclick="for (var i=0;i<7;++i) document.getElementsByName('r<?php print $r ?>c'+i)[0].value=''"/>
<input type="button" value="#" title="activate / deactivate"
onclick="var v=document.getElementsByName('r<?php print $r ?>c0')[0];
if (v.value.charAt(0)!='#') v.value='#'+v.value;else v.value=v.value.substring(1); mark('r<?php print $r ?>')"/>
<?php }
print '<br/>';
}
$rmax=2+$r++;
for($r;$r<=$rmax;$r++) {
print '<input title="*|0..59: 8 1,3,5 2-5 * */2" name="r'.$r.'c0" type="text" size="8" value=""/>';
print '<input title="*|0..23: 8 1,3,5 2-5 * */2" name="r'.$r.'c1" type="text" size="7" value=""/>';
print '<input title="*|1..31: 8 1,3,5 2-5 * */2" name="r'.$r.'c2" type="text" size="7" value=""/>';
print '<input title="*|1..12: 8 1,3,5 2-5 * */2" name="r'.$r.'c3" type="text" size="7" value=""/>';
print '<input title="*|0..7: so=0/7 sa=6" name="r'.$r.'c4" type="text" size="7" value=""/>';
print '<input name="r'.$r.'c5" type="text" size="7" value=""/>';
print '<input name="r'.$r.'c6" type="text" size="40" value=""/>';
?>
<input type="button" value="X" title="delete"
onclick="for (var i=0;i<7;++i) document.getElementsByName('r<?php print $r ?>c'+i)[0].value=''"/>
<input type="button" value="#" title="activate / deactivate"
onclick="var v=document.getElementsByName('r<?php print $r ?>c0')[0];
if (v.value.charAt(0)!='#') v.value='#'+v.value;else v.value=v.value.substring(1); mark('r<?php print $r ?>')"/><br/>
<?php } ?>
<input type="hidden" name="rows" value="<?php print --$r ?>"/>
<input type="button" value="save /etc/crontab & restart crond" style="margin-top:6px"
onclick="document.getElementById('action').value='save';submit()"/>
</form></body></html>
- Mar 28 Wed 2012 21:50
-
php讀取csv的方法
php讀取csv的方法:
$dbname="import.csv"; //開啟
if ( !$fp = fopen($dbname,"r") ) { //假如開啟錯誤
echo "Cannot open $dbname\n"; //顯示錯誤
exit;
}else{ //開啟成功
$size = filesize($dbname)+1; //取得筆數
$row=0; //從0筆開始讀取
while($temp=fgetcsv($fp,$size,",")){ //讀取csv資料給temp陣列
if ($row>0){ //假如筆數大於0
$sql="INSERT INTO `a` ( `a1` , `a2` , `a5` ) VALUES ('$temp[1]','$temp[0]','$temp[15]')"; //寫入資料庫
$result=mysql_query($sql); //執行
}
$row=$row+1;
}
fclose($fp); //關閉檔案
}
$dbname="import.csv"; //開啟
if ( !$fp = fopen($dbname,"r") ) { //假如開啟錯誤
echo "Cannot open $dbname\n"; //顯示錯誤
exit;
}else{ //開啟成功
$size = filesize($dbname)+1; //取得筆數
$row=0; //從0筆開始讀取
while($temp=fgetcsv($fp,$size,",")){ //讀取csv資料給temp陣列
if ($row>0){ //假如筆數大於0
$sql="INSERT INTO `a` ( `a1` , `a2` , `a5` ) VALUES ('$temp[1]','$temp[0]','$temp[15]')"; //寫入資料庫
$result=mysql_query($sql); //執行
}
$row=$row+1;
}
fclose($fp); //關閉檔案
}
- Mar 18 Sun 2012 21:05
-
php執行javaScript的語法
php執行javaScript的語法
echo "<script language=\"JavaScript\">";
echo "window.alert(\"你未登入\");"; //警告對話方塊
echo "location.href(\"./\");"; //到首頁
echo "</script>";
- Nov 03 Thu 2011 10:07
-
在刪除資料庫前確認
在<head>與</head>之間放下面語法:
<script type="text/javascript">
function MM_goToURL() { //v3.0
var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
</script>
- Nov 03 Thu 2011 09:22
-
檢查ta1~ta20與tanser1~20是否相同,$score分數+5分
檢查ta1~ta20與tanser1~20是否相同,$score分數+5分
$score=0;
for($i=1;$i<=20;$i++){
$ta="ta" . $i;
$tb="tanser" . $i;
if( $_POST[$ta]==$_POST[$tb]){
$score += 5;
}
}
- Nov 02 Wed 2011 17:11
-
從資料庫的資料表內把資料亂數取出
//取得總筆數
mysql_select_db($database_conn, $conn);
$query_rec_pro = sprintf("SELECT * FROM $ta");
$rec_pro = mysql_query($query_rec_pro, $conn) or die(mysql_error());
$row_rec_pro = mysql_fetch_assoc($rec_pro);
$totalRows_rec_pro = mysql_num_rows($rec_pro);
- Nov 02 Wed 2011 17:07
-
PHP產生不重覆亂數寫入陣列
<?php
for($i=1;$i<=20;$i++){ //產生20個
$b=rand(1,25); //產生1~25的亂數
for($j=1;$j<=$i;$j++){ //檢查重覆
if($b==$a[$j]){
$b=rand(1,25); //如果重覆,重新產生亂數
$j=0;
}
}
$a[$i]=$b; //寫入陣列
}
arsort($a); //排序
foreach($a as $value){ //把陣列內的亂數讀出
echo $value . "<br />";
}
?>


