| -x | ディレクトリを作成する |
| -r | 下位ディレクトリまで取ってくる |
| -b | 詳細を表示しない |
| -nc | 新しいものだけ |
| -o | ログを出力 |
投稿者: masomi79
in_array serch_array
$hogehoge = array();
for($i=0;$i>=100;$i++){
if(($i%3) == 0){
array_push($hogehoge,$i);
}
}
if(in_array($check,$hogehoge)){
print "その数は配列に存在します";
}else{
print "その数は配列に存在しません";
}
選択するとジャンプするセレクトボックス
<head>に記述
<script type='text/javascript'>
<!--
var target = '';
function jump(){
var url = document.form1.select.options[document.form1.select.selectedIndex].value;
if(url != '' ){
if(target == 'top'){
top.location.href = url;
}
else if(target == 'blank'){
window.open(url, 'window_name');
}
else if(target != ''){
eval('parent.' + target + '.location.href = url');
}
else{
location.href = url;
}
}
}
// -->
</script>
<body>に記述
<form action="#" name="form1"> <select name="select" onChange="jump()"> <option value='hogehoge1.php?id=1'>hogehoge1</option> <option value='hogehoge1.php?id=2'>hogehoge2</option> <option value='hogehoge1.php?id=3'>hogehoge3</option> </select> </form>
ディレクトリの一括削除
rm -rf hogehoge
確認もされないので注意。
現在のurlを取得する $_SERVER['REQUEST_URI']
ユーザーが選択した結果に基づいて生成されたページにさらに変数をくっつけてリロードする場合
$_SERVER['REQUEST_URI']
で現在の状態のURLを取得できます。
例えば
http://www.hogehoge.org/index.html?option=QrYQZRQVNQsNZN
のページで
$link = $_SERVER['REQUEST_URI'];
としておいて
<a href='" . $link . "&option2=hoge'>
とすると
http://www.hogehoge.org/index.html?option=QrYQZRQVNQsNZN&option2=hoge
へのリンクが作れます。
array_push データベースから抽出したデータを配列に格納する
$_hogehoge = array(); //配列を初期化
//SQLを実行
$sql = "select id from tbl_hoge";
$rst = mysql_query($sql,$con);
//抽出したデータを一件ずつ配列の最後に格納していく
while($row = mysql_fetch_array($rst)) {
array_push($_hogehoge,$row["id"]);
}
print_r($_hogehoge);
割り算の余りの処理
| floor | 余りを切り捨てる |
| ceil | 余りを切り上げる |
| round | 四捨五入 |
$x = 10; $y = 3; print floor($x / $y); print ceil($x / $y); print round($x / $y);
- :実行結果:::
343
round は四捨五入する際の桁数も指定できます
print round($x / $y, 3);
- :実行結果:::
3.333
文字コードを指定してデータベースを作成する
my.cnfを設定する
設定の確認↓
mysql> status -------------- mysql Ver 14.7 Distrib 4.1.22, for redhat-linux-gnu (x86_64) using readline 4.3 | | | Server characterset: latin1 Db characterset: latin1 Client characterset: latin1 Conn. characterset: latin1 | | | --------------
インストール直後の文字コードを見ると”latin1″とかになっているので、
コレをunicodeに変更します。
/etc とかにあるmy.cnfを設定。
それぞれの項目に以下を追加します。
[mysqld] default-character-set=utf8 skip-character-set-client-handshake [client] default-character-set = utf8 [mysqldump] default-character-set = utf8 [mysql] default-character-set = utf8
mysqldを再起動。
#service mysqld restart
mysqlを起動して設定を確認すると。。。
mysql> status -------------- mysql Ver 14.7 Distrib 4.1.22, for redhat-linux-gnu (x86_64) using readline 4.3 | | | Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 | | | mysql>
http://d.hatena.ne.jp/shimonoakio/20080129/1201609465
http://tod.cocolog-nifty.com/diary/2005/12/xamppphpmysql_6279.html
テーブルへフィールドを追加
alter table [テーブル名] add [フィールド名] [データ型]