hotmail: 大人っぽいデザインです。

gmail:やすっぽい印象があり、あまり好きではない

yahoo:ごちゃごちゃしていて見にくい

アマゾン:特に感想なし

テキスト小さめで、ヘッダーは黒・紺の方が落ち着いて見える気がします。
初期画面

ソフトウェアエンジニアの技術ブログ:Software engineer tech blog
随机应变 ABCD: Always Be Coding and … : хороший
hotmail: 大人っぽいデザインです。

gmail:やすっぽい印象があり、あまり好きではない

yahoo:ごちゃごちゃしていて見にくい

アマゾン:特に感想なし

テキスト小さめで、ヘッダーは黒・紺の方が落ち着いて見える気がします。
初期画面

amazon: カッケー

hotmail: 渋い

yahoo: ヤフーっぽい感じが出てて、なんか好感持てる!

google: ああ、登録画面はGoogleが一番いいかも。特にセキュリティをケアしているところが好きだ。

どこも、基本はログインの画面と整合性が取れてますね。
なるほど!
初期画面

css
.form1{
width:100%;
height:30px;
margin-top:5px;
}
.submit {
width:100%;
height:30px;
margin-top:5px;
background-color:#0099FF;
color:#fff;
border:0px;
}
select{
width:100%;
height:30px;
margin-bottom:5px;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
border: 1px solid #999;
padding-left:5px;
}
修正後 ->
適当だけど雰囲気はそれっぽい(笑)

なんじゃこれ、よく見たら、全部カッケーーーーーー すげーーーーー
ホットメール

gmail

yahoo

twitter

facebook

LINE

Amazon

なんだよこれ、2回言うけど、全部カッケー
すげーなー
input formはyahoo, facebookを除いて中央寄せがトレンドのようですね。
初期画面

スタイリングしていきます。
<div class="signin">
<h1>サインイン</h1>
<form method="POST" action="login.php">
<input type="text" name="username" placeholder="ユーザー名"/><br>
<input type="password" name="password" placeholder="パスワード"/><br>
<input type="submit" value="ログイン" />
</form>
※アカウントを持ちでない場合、<a href="register.php">新規登録</a>できます。
</div>
css
body{
background-color:#EEEEEE;
}
.signin{
background-color:#fff;
margin:50 auto;
padding-top:10px;
padding-left:10px;
width:400px;
height:400px;
}

更にスタイリング
body{
background-color:#EEEEEE;
}
.signin{
background-color:#fff;
margin:50 auto;
padding-top:10px;
padding-left:10px;
padding-right:10px;
width:400px;
height:400px;
}
.form1{
width:100%;
height:30px;
margin-top:5px;
}
.submit {
width:100%;
height:30px;
margin-top:5px;
background-color:#0099FF;
color:#fff;
border:0px;
}
#fs-s{
font-size:small;
color:gray;
}
おおお、それっぽい(笑)

「これ、絶対もっと効率的に書ける筈」、と思いながら結局、POSTされた際のsqlのパターンを全部書いてしまった。
終わってる。死にたい。。
concatの値がnullがある場合は、ifnullを使います。
CONCAT(IFNULL(username, ”), IFNULL(message, ”))
<?php
$dsn = "mysql:dbname=mail;host=localhost";
$user = "hoge";
$password = "hogehoge";
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e){
print('connection failed:'.$e->getMessage());
}
if(!empty($_POST["search"]) and !empty($_POST["gender"]) and !empty($_POST["age"]) and !empty($_POST["job"]) and !empty($_POST["area"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and gender = '".$_POST["gender"]."' and age = '".$_POST["age"]."' and job = '".$_POST["job"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["age"]) and !empty($_POST["job"]) and !empty($_POST["area"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and age = '".$_POST["age"]."' and job = '".$_POST["job"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["gender"]) and !empty($_POST["job"]) and !empty($_POST["area"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and gender = '".$_POST["gender"]."' and job = '".$_POST["job"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["gender"]) and !empty($_POST["age"]) and !empty($_POST["area"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and gender = '".$_POST["gender"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["gender"]) and !empty($_POST["age"]) and !empty($_POST["job"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and gender = '".$_POST["gender"]."' and age = '".$_POST["age"]."' and job = '".$_POST["job"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["job"]) and !empty($_POST["area"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and job = '".$_POST["job"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["age"]) and !empty($_POST["area"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and age = '".$_POST["age"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["age"]) and !empty($_POST["job"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and age = '".$_POST["age"]."' and job = '".$_POST["job"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["gender"]) and !empty($_POST["area"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and gender = '".$_POST["gender"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["gender"]) and !empty($_POST["job"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and gender = '".$_POST["gender"]."' and job = '".$_POST["job"]."' and order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["gender"]) and !empty($_POST["age"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and gender = '".$_POST["gender"]."' and age = '".$_POST["age"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["gender"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and gender = '".$_POST["gender"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["age"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and age = '".$_POST["age"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["job"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and job = '".$_POST["job"]."' order by id desc";
}elseif(!empty($_POST["search"]) and !empty($_POST["area"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["search"])){
$sql = "select * from users where CONCAT(IFNULL(username, ''), IFNULL(message, '')) like '%".$_POST["search"]."%' order by id desc";
}elseif(!empty($_POST["gender"]) and !empty($_POST["age"]) and !empty($_POST["job"]) and !empty($_POST["area"])){
$sql = "select * from users where gender = '".$_POST["gender"]."' and age = '".$_POST["age"]."' and job = '".$_POST["job"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["gender"]) and !empty($_POST["job"]) and !empty($_POST["area"])){
$sql = "select * from users where gender = '".$_POST["gender"]."' and job = '".$_POST["job"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["gender"]) and !empty($_POST["age"]) and !empty($_POST["area"])){
$sql = "select * from users where gender = '".$_POST["gender"]."' and age = '".$_POST["age"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["gender"]) and !empty($_POST["age"]) and !empty($_POST["job"])){
$sql = "select * from users where gender = '".$_POST["gender"]."' and age = '".$_POST["age"]."' and job = '".$_POST["job"]."' order by id desc";
}elseif(!empty($_POST["gender"]) and !empty($_POST["area"])){
$sql = "select * from users where gender = '".$_POST["gender"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["gender"]) and !empty($_POST["job"])){
$sql = "select * from users where gender = '".$_POST["gender"]."' and job = '".$_POST["job"]."' order by id desc";
}elseif(!empty($_POST["gender"]) and !empty($_POST["age"])){
$sql = "select * from users where gender = '".$_POST["gender"]."' and age = '".$_POST["age"]."' order by id desc";
}elseif(!empty($_POST["gender"])){
$sql = "select * from users where gender = '".$_POST["gender"]."' order by id desc";
}elseif(!empty($_POST["age"]) and !empty($_POST["job"]) and !empty($_POST["area"])){
$sql = "select * from users where age = '".$_POST["age"]."' and job = '".$_POST["job"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["age"]) and !empty($_POST["area"])){
$sql = "select * from users where age = '".$_POST["age"]."' and area = '".$_POST["area"]."' order by id desc";
}elseif(!empty($_POST["age"]) and !empty($_POST["job"])){
$sql = "select * from users where age = '".$_POST["age"]."' and job = '".$_POST["job"]."' order by id desc";
}elseif(!empty($_POST["age"])){
$sql = "select * from users where age = '".$_POST["age"]."' order by id desc";
}elseif(!empty($_POST["job"]) and !empty($_POST["area"])){
$sql = "select * from users where job = '".$_POST["job"]."' and are = '".$_POST["are"]."' order by id desc";
}elseif(!empty($_POST["job"])){
$sql = "select * from users where job = '".$_POST["job"]."' order by id desc";
}elseif(!empty($_POST["area"])){
$sql = "select * from users where area = '".$_POST["area"]."' order by id desc";
}else{
$sql = "select * from users order by id desc";
}
$stmt = $dbh->query($sql);
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
// var_dump($result);
?>
<style>
#img{
position: relative;
}
#img img{
vertical-align:top;
}
#icon{
vertical-align:top;
float:left;
}
#profile{
display: inline;
}
</style>
<form action="" method="post"><input type="search" name="search" placeholder="ユーザー名もしくは一言メッセージから探す"> <input type="submit" value="検索"><br>
性別:<input type="radio" name="gender" value="男性">男性
<input type="radio" name="gender" value="女性">女性
年齢:
<select name="age">
<option value="">選択してください</option>
<option value="20歳未満">20歳未満</option>
<option value="20-24歳">20-24歳</option>
<option value="25-29歳">25-29歳</option>
<option value="30-34歳">30-34歳</option>
<option value="35-39歳">35-39歳</option>
<option value="40-44歳">40-44歳</option>
<option value="45-49歳">45-49歳</option>
<option value="50-54歳">50-54歳</option>
<option value="55-59歳">55-59歳</option>
<option value="60-64歳">60-64歳</option>
<option value="65-69歳">65-69歳</option>
<option value="70-74歳">70-74歳</option>
<option value="75-79歳">75-79歳</option>
<option value="80歳以上">80歳以上</option>
</select>
職業:
<select name="job">
<option value="">選択してください</option>
<option value="公務員">公務員</option>
<option value="経営者・役員">経営者・役員</option>
<option value="会社員">会社員</option>
<option value="自営業">自営業</option>
<option value="自由業">自由業</option>
<option value="専業主婦">専業主婦</option>
<option value="パート・アルバイト">パート・アルバイト</option>
<option value="学生">学生</option>
<option value="その他">その他</option>
</select>
登録地域:
<select name="area">
<option value="">選択してください</option>
<option value="北海道">北海道</option>
<option value="青森県">青森県</option>
<option value="岩手県">岩手県</option>
<option value="宮城県">宮城県</option>
<option value="秋田県">秋田県</option>
<option value="山形県">山形県</option>
<option value="福島県">福島県</option>
<option value="茨城県">茨城県</option>
<option value="栃木県">栃木県</option>
<option value="群馬県">群馬県</option>
<option value="埼玉県">埼玉県</option>
<option value="千葉県">千葉県</option>
<option value="東京都">東京都</option>
<option value="神奈川県">神奈川県</option>
<option value="新潟県">新潟県</option>
<option value="富山県">富山県</option>
<option value="石川県">石川県</option>
<option value="福井県">福井県</option>
<option value="山梨県">山梨県</option>
<option value="長野県">長野県</option>
<option value="岐阜県">岐阜県</option>
<option value="静岡県">静岡県</option>
<option value="愛知県">愛知県</option>
<option value="三重県">三重県</option>
<option value="滋賀県">滋賀県</option>
<option value="京都府">京都府</option>
<option value="大阪府">大阪府</option>
<option value="兵庫県">兵庫県</option>
<option value="奈良県">奈良県</option>
<option value="和歌山県">和歌山県</option>
<option value="鳥取県">鳥取県</option>
<option value="島根県">島根県</option>
<option value="岡山県">岡山県</option>
<option value="広島県">広島県</option>
<option value="山口県">山口県</option>
<option value="徳島県">徳島県</option>
<option value="香川県">香川県</option>
<option value="愛媛県">愛媛県</option>
<option value="高知県">高知県</option>
<option value="福岡県">福岡県</option>
<option value="佐賀県">佐賀県</option>
<option value="長崎県">長崎県</option>
<option value="熊本県">熊本県</option>
<option value="大分県">大分県</option>
<option value="宮崎県">宮崎県</option>
<option value="鹿児島県">鹿児島県</option>
<option value="沖縄県">沖縄県</option>
<option value="海外">海外</option>
</select><br>
</form>
<?php
$i = 0;
foreach($result as $value){
if($i < 20){
if(!empty($value["icon"])){
$picon = $value["icon"];
echo "<img src=\"".$picon."\" id=\"icon\" width=\"48px\" height=\"48px\">";
} elseif($value['gender'] == "男性") {
echo "<img src=\"asset/img/male.png\" id=\"icon\">";
} else{
echo "<img src=\"asset/img/female.png\" id=\"icon\">";
}
echo "<div id=\"profile\"><a href=\"?compose=new&to=".$value['username']."\">".$value['username'] ."</a>:".$value['age']." <span id=\"fs-s\">".$value['gender'] ."</span><br>";
if(!empty($value["message"])){
echo $value['job']."(".$value['area'].") <span id=\"fs-s\">一言メッセージ:「".$value["message"]."」</span></div><br><br>";
} else {
echo $value['job']."(".$value['area'].")</div><br><br>";
}
$i++;
}
}
挙動としては、思い通りに動いてくれるんだが、自分にがっかりするな。。

つなげると、
おおおお、基本機能はほぼ出来たか!


次は、スタイリングかな
<?php
if(isset($_POST["violation"])){
$subject = "メール違反報告" .$_POST["mailid"];
$body = "ユーザー名:".$_POST["name"]. "\n";
$body .= "違反内容:".$_POST["violation"]. "\n";
$body .= "詳細:". htmlspecialchars($_POST["report"]);
$header = "From: hoge@hoge.com\r\n";
mb_send_mail("hogehoge@gmail.com", $subject, $body, $header);
}
$mailid = empty($_GET["inbox"])? 'null' : $_GET["inbox"];
$name = empty($_GET["from"])? '' : $_GET["from"];
?>
<style>
#caution {
color:gray;
font-size:small;
}
</style>
<?php if(!empty($_GET["from"])): ?>
法律やガイドラインに違反していると思われたメールを受信した場合は、このフォームから報告できます。<hr>
<form method="POST" action="?help=done">
違反項目:
<select name="violation">
<option value="なし">選択してください</option>
<option value="広告、もしくはPR">広告、もしくはPR</option>
<option value="同じ内容を繰り返し送信">同じ内容を繰り返し送信</option>
<option value="アダルト・罵倒雑言">アダルト・罵倒雑言</option>
<option value="個人情報を含む投稿">個人情報を含む投稿</option>
<option value="著作権、知的所有権の侵害">著作権、知的所有権の侵害</option>
<option value="その他">その他</option>
</select>
<br><br>
報告内容(全角100文字以内で入力してください)<br>
<textarea maxlength="100" name="report" rows="8" cols="100%">
</textarea>
<br>
<div id="caution">
・いただいた報告に個別にお答えすることはありません。<br>
・いただいた報告に基づいて対応、処置することをお約束するものではありません。
</div><br>
<input type="hidden" name="name" value="<?php echo $name; ?>">
<input type="hidden" name="mailid" value="<?php echo $mailid; ?>">
<input type="submit" value="報告する">
<?php elseif($_GET["help"] == 'done'): ?>
<p>報告が完了しました。</p>
<?php endif; ?>

受信側

つなげると、

さあ、最後、会員検索機能!
項目がemptyでpostされた場合は、更新なし(元のデータでupdate set)する。
$stmt2 = $dbh -> prepare("update users set age = :age, job = :job, area = :area, message = :message, icon = :icon where username = '".$username."'");
if(!empty($_POST["age"])){
$stmt2->bindParam(':age', $age, PDO::PARAM_STR);
} else {
$stmt2->bindParam(':age', $result['age'], PDO::PARAM_STR);
}
if(!empty($_POST["job"])){
$stmt2->bindParam(':job', $job, PDO::PARAM_STR);
}else {
$stmt2->bindParam(':job', $result['job'], PDO::PARAM_STR);
}
if(!empty($_POST["area"])){
$stmt2->bindParam(':area', $area, PDO::PARAM_STR);
} else {
$stmt2->bindParam(':area', $result['area'], PDO::PARAM_STR);
}
$stmt2->bindParam(':message', $message, PDO::PARAM_STR);
if(!empty($_FILES["file"]["name"])){
$stmt2->bindParam(':icon', $file, PDO::PARAM_STR);
} else {
$stmt2->bindParam(':icon', $result['icon'], PDO::PARAM_STR);
}
$stmt2->execute();
更新前

更新後


マッチング画面
一言メッセージがある場合のみ、表示
if(!empty($value["message"])){
echo $value['job']."(".$value['area'].") 一言メッセージ:".$value["message"]."</div><br><br>";
} else {
echo $value['job']."(".$value['area'].")</div><br><br>";
}
割とすぐできた!

あとは、1.メールの違反報告機能、2.会員検索機能 といったところでしょうか。
以下はtextreamの違反報告
なるほど、mordalか~~~

1.新しく登録されたユーザー順に抽出(mysqlのidをorder by id desc)
2.ログイン中のユーザーと同じ登録エリアかつ年齢が同じなら、id x 1.3 のスコア
3.ログイン中のユーザーと同じ登録エリアなら、 id x 1.2 のスコア
4.ログイン中のユーザーと同じ年齢なら id x 1.1 のスコア
5.array_multisortでスコア順にソート
6.ログイン中のユーザーと異なる異性をスコア順に表示
※新しく登録された同じエリア・年齢のユーザーが上に表示されやすくなる
<style>
#fs-s{
font-size:small;
color:gray;
}
#icon{
vertical-align:top;
float:left;
}
#profile{
display: inline;
}
</style>
<?php
session_start();
$username = $_SESSION["username"];
$dsn = "mysql:dbname=mail;host=localhost";
$user = "hoge";
$password = "hogehoge";
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e){
print('connection failed:'.$e->getMessage());
}
$sql = "select * from users order by id desc";
$stmt = $dbh->query($sql);
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
// var_dump($result);
$sql2 = "select * from users where username = '".$username."'";
$stmt2 = $dbh->query($sql2);
$result2 = $stmt2->fetch(PDO::FETCH_ASSOC);
$gender = $result2["gender"];
$area = $result2["area"];
$age = $result2["age"];
$i = 0;
foreach($result as $value){
if($value["area"] == $area){
if($value["age"] == $age){
$result[$i]["score"] = (int)$value["id"] * 1.3;
$score[$i] = $result[$i]["score"];
} else{
$result[$i]["score"] = (int)$value["id"] * 1.2;
$score[$i] = $result[$i]["score"];
}
} else {
if($value["age"] == $age){
$result[$i]["score"] = (int)$value["id"] * 1.1;
$score[$i] = $result[$i]["score"];
} else{
$result[$i]["score"] = (int)$value["id"];
$score[$i] = $result[$i]["score"];
}
}
$i++;
}
array_multisort($score, SORT_DESC, $result);
switch($gender){
case '男性':
$img = "asset/img/female.png";
break;
case '女性':
$img = "asset/img/male.png";
}
$i = 0;
foreach($result as $value){
if($gender != $value['gender']){
echo "<img src=\"".$img."\" id=\"icon\">";
echo "<div id=\"profile\"><a href=\"\">".$value['username'] ."</a>:".$value['age']." <span id=\"fs-s\">".$value['gender'] ."</span><br>";
echo $value['job']."(".$value['area'].")</div><br><br>";
}
$i++;
}
?>
神奈川県 男性 25-29歳がログインしていた場合

つなげると、

名前をクリックすると、相手にメールを送れるようにする。
foreach($result as $value){
if($gender != $value['gender'] and $i < 10){
echo "<img src=\"".$icon."\" id=\"icon\">";
echo "<div id=\"profile\"><a href=\"?compose=new&to=".$value['username']."\">".$value['username'] ."</a>:".$value['age']." <span id=\"fs-s\">".$value['gender'] ."</span><br>";
echo $value['job']."(".$value['area'].")</div><br><br>";
$i++;
}
}

女性で登録してログインした場合

送信後

あれあれあれ?もしかして、結構できてきた!???
プロフィール編集画面をつくって、「プロフィール写真」と「一言メッセージ」を加えて、法律とセキュリティを見直したら、基本的なところはほぼ完成か?

Alter table add firstですね。
ALTER TABLE users ADD id int unsigned auto_increment primary key FIRST;
input formも修正します。
<input type="radio" name="gender" value="男性" checked>男性 <input type="radio" name="gender" value="女性">女性<br> 年齢: <select name="age"> <option value="">選択してください</option> <option value="20歳未満">20歳未満</option> <option value="20-24歳">20-24歳</option> <option value="25-29歳">25-29歳</option> <option value="30-34歳">30-34歳</option> <option value="35-39歳">35-39歳</option> <option value="40-44歳">40-44歳</option> <option value="45-49歳">45-49歳</option> <option value="50-54歳">50-54歳</option> <option value="55-59歳">55-59歳</option> <option value="60-64歳">60-64歳</option> <option value="65-69歳">65-69歳</option> <option value="70-74歳">70-74歳</option> <option value="75-79歳">75-79歳</option> <option value="80歳以上">80歳以上</option>
sqlもorder by id descとします。
$sql = "select * from users order by id desc";
女性でログインすると、男性だけ表示されます。

画像を追加
switch($gender){
case '男性':
$img = "asset/img/female.png";
break;
case '女性':
$img = "asset/img/male.png";
}
$i = 0;
foreach($gender_lists as $value){
if($gender != $value){
echo "<img src=\"".$img."\" id=\"icon\">";
echo "<div id=\"profile\"><a href=\"\">".$name_lists[$i] ."</a>:".$age_lists[$i]." <span id=\"fs-s\">".$gender_lists[$i] ."</span><br>";
echo $job_lists[$i]."(".$area_lists[$i].")</div><br><br>";
}
$i++;
}


問題は、年齢が近い人と、エリアが近い人をどういうロジックで計算させるかなんだが、
あれ? これはよくわからんぞ。
autoincrementのidをbase scoreにして、それにsliceした先頭2桁の年齢が近ければ点数を加算して、in_arrayで都道府県が近隣であれば更に点数を加算でOK?
まず、ログイン中ユーザのgenderを取得し、男性であれば女性を、女性であれば男性のプロフィールを表示して、メールを送れるようにする。
<style>
#fs-s{
font-size:small;
color:gray;
}
</style>
<?php
session_start();
$username = $_SESSION["username"];
$dsn = "mysql:dbname=mail;host=localhost";
$user = "hoge";
$password = "hogehoge";
try {
$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e){
print('connection failed:'.$e->getMessage());
}
$sql = "select * from users";
$stmt = $dbh->query($sql);
while($result = $stmt->fetch(PDO::FETCH_ASSOC)){
if($result['username'] == $username){
$gender = $result['gender'];
} else {
$name_lists[] = $result['username'];
$gender_lists[] = $result['gender'];
$age_lists[] = $result['age'];
$area_lists[] = $result['area'];
$job_lists[] = $result['job'];
}
}
$i = 0;
foreach($gender_lists as $value){
if($gender != $value){
echo "<a href=\"\">".$name_lists[$i] ."</a>:".$age_lists[$i]." <span id=\"fs-s\">".$gender_lists[$i] ."</span><br>";
echo $job_lists[$i]."(".$area_lists[$i].")<br><br>";
}
$i++;
}

1.mail, femaleではなく、”男性”、”女性”
2.ソートにorder by を使いたいので、usersにもidのカラムが必要
3.年齢は5歳刻み
4.やはりアイコン写真が欲しい
public function register($username, $password, $gender, $age, $area, $job){
$ip = $_SERVER["REMOTE_ADDR"];
$password = password_hash($_POST["password"], PASSWORD_DEFAULT);
$stmt = $this->mysqli->prepare("INSERT INTO users (username, password, gender, age, area, job, ip) VALUES(?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param('sssssss', $_POST["username"], $password, $_POST["gender"], $_POST["age"], $_POST["area"], $_POST["job"], $ip);
return $stmt->execute();
}
mysql
int型だと、”.”がはじかれるので、varcharに変更します。
| student | $2y$10$kJtKFIht9YDow8rOwx…hoge | male | 20歳未満 | 東京都 | 学生 | 192168 |
alter table users change ip ip varchar(41);
OKですね。後で、ipをuniqueにすれば、同じipアドレスで重複して登録できなくなります。
| endo | $2y$10$66Cp8MFw9..hoge | male | 20-29歳 | 東京都 | 学生 | 192.168.33.1 |

さぁ~、いよいよ マッチングの設計をしていきましょう!!!
一応、facebookの「知り合いかも」のUIを見てみましょう。
「写真」「名前」「職業」「友達になる」「共通の知り合い」が表示されてますね。

プロフィール写真の表示は後からuploadする機能を追加するとして、表示項目としては、異性の「username」「age」「job」「メールを送る」ってところですかね。
あ、「一言メッセージ」も追加しときますかね。
初期の表示アルゴリズムは、「新しく登録された順」、「年齢が近い」、「登録エリアが近い」に毎回シャッフルした係数を掛けてsort って感じがいいかな。