-
Notifications
You must be signed in to change notification settings - Fork 0
추천.php
woosoo2 edited this page Mar 7, 2014
·
10 revisions
http://www.finfra.com/~tv11/ssample.php
<?php
$sex=$_GET["sex"];
$style=$_GET["style"];
if ($sex == NULL && $style==NULL) {
$sql_t = "select tid,tname,url_1 from top";
$sql_b = "select bid,bname,url_1 from bot";
} elseif($sex!=NULL && $style==NULL) {
$sql_t = "select tid,tname,url_1 from top where sex='".$_GET["sex"]."'";
$sql_b = "select bid,bname,url_1 from bot where sex='".$_GET["sex"]."'";
} elseif($sex==NULL && $style!=NULL) {
$sql_t = "select tid,tname,url_1 from top where style='".$_GET["style"]."'";
$sql_b = "select bid,bname,url_1 from bot where style='".$_GET["style"]."'";
} else{
$sql_t = "select tid,tname,url_1 from top where sex='".$_GET["sex"]."' and style='".$_GET["style"]."'";
$sql_b = "select bid,bname,url_1 from bot where sex='".$_GET["sex"]."' and style='".$_GET["style"]."'";
}
// Check connection
$con=mysql_connect("localhost","tv11","imtv11");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("tv11", $con);
//top
$result_t = mysql_query($sql_t);
$resultArray = array();
$i=0;
while($row = mysql_fetch_array($result_t)){
$resultArray["detailTop"][$i]=array();
$resultArray["detailTop"][$i]["tid"]=$row["tid"];
$resultArray["detailTop"][$i]["tname"]=$row["tname"];
$resultArray["detailTop"][$i]["url_1"]=$row["url_1"];
$i++;
}
//bot
$result = mysql_query($sql_b);
$i=0;
while($row = mysql_fetch_array($result)){
$resultArray["detailBot"][$i]=array();
$resultArray["detailBot"][$i]["bid"]=$row["bid"];
$resultArray["detailBot"][$i]["bname"]=$row["bname"];
$resultArray["detailBot"][$i]["url_1"]=$row["url_1"];
$i++;
}
echo "". json_encode($resultArray,JSON_UNESCAPED_UNICODE) . "";
mysql_close($con);
?>{
"detailTop": [
{
"tid": "Num",
"tname": "Name_val",
"url_1": "Pic_addr"
},
.
.
.
],
"detailBot": [
{
"bid": "Num",
"bname": "Name_val",
"url_1": "Pic_addr"
},
.
.
.
]
}