HTML:saucydares.freehostia.com/saucy.php我应该补充一点,虽然没有图片,但该网站包含成人主题,因此不安全。
PHP:
<?php
mysql_connect("mysql4.freehostia.com", sebsal2_db, "");
function him()
{
$HIMquery = "SELECT dares FROM sebsal2_db.him UNION SELECT dares FROM sebsal2_db.other ORDER BY Rand() LIMIT 1";
$HIMresult = mysql_query($HIMquery);
while ($HIMrow = mysql_fetch_array($HIMresult, MYSQL_NUM)) {echo "$HIMrow[0]";}
}
function her()
{
$HERquery = "SELECT dares FROM sebsal2_db.her UNION SELECT dares FROM sebsal2_db.other ORDER BY Rand() LIMIT 1";
$HERresult = mysql_query($HERquery);
while ($HERrow = mysql_fetch_array($HERresult, MYSQL_NUM)) {echo "$HERrow[0]";}
}
function double()
{
$DOUBLEquery = "SELECT dares FROM sebsal2_db.double ORDER BY Rand() LIMIT 1";
$DOUBLEresult = mysql_query($DOUBLEquery);
while ($DOUBLErow = mysql_fetch_array($DOUBLEresult, MYSQL_NUM)) {echo "$DOUBLErow[0]";}
}
function himlong()
{
$HIMLONGquery = "SELECT dares FROM sebsal2_db.him2 UNION SELECT dares FROM sebsal2_db.other2 ORDER BY Rand() LIMIT 1";
$HIMLONGresult = mysql_query($HIMLONGquery);
while ($HIMLONGrow = mysql_fetch_array($HIMLONGresult, MYSQL_NUM)) {echo "$HIMLONGrow[0]";}
}
function herlong()
{
$HERLONGquery = "SELECT dares FROM sebsal2_db.her2 UNION SELECT dares FROM sebsal2_db.other2 ORDER BY Rand() LIMIT 1";
$HERLONGresult = mysql_query($HERLONGquery);
while ($HERLONGrow = mysql_fetch_array($HERLONGresult, MYSQL_NUM)) {echo "$HERLONGrow[0]";}
}
function doublelong()
{
$DOUBLELONGquery = "SELECT dares FROM sebsal2_db.double2 ORDER BY Rand() LIMIT 1";
$DOUBLELONGresult = mysql_query($DOUBLELONGquery);
while ($DOUBLELONGrow = mysql_fetch_array($DOUBLELONGresult, MYSQL_NUM)) {echo "$DOUBLELONGrow[0]";}
}
var_dump($_POST)
/* $mode = mysql_real_escape_string($_POST['mode']);
$player = mysql_real_escape_string($_POST['player']);
echo $player;
echo $mode;
if ($player=="For him" && $mode=="Classic Collection") {
him();
}
if ($player=="For her" && $mode=="Classic Collection") {
her();
}
if ($player=="Double dare" && $mode=="Classic Collection") {
double();
}
if ($player=="For him" && $mode=="The Long Game") {
himlong();
}
if ($player=="For her" && $mode=="The Long Game") {
herlong();
}
if ($player=="Double dare" && $mode=="The Long Game") {
doublelong();
}
*/
?>
它旨在读取两个下拉列表,并根据组合显示mySQL数据库中的随机字段。回应变量不是永久性的,只是一个测试。两个问题:
如果选择,使用var_dump($ _ POST) 经典系列它看到了所有 右侧框中的选项为“For 他“如果你选择长游戏 它认为它们是“为了她”。
因此if语句 不工作。
感谢您的回复!
答案 0 :(得分:1)
价值观是'他','她'不是'为了他','为了她'
答案 1 :(得分:0)
您的代码可能会使用一些严重的冷凝。 if语句应该是嵌套的,并且函数可以使用参数压缩到一个函数。一个可能的函数签名:
function game($player, $mode)
然后根据参数在函数内部建立业务逻辑和查询。