如果他们的id等于1,我想取一个字段的所有成员。
数据库:
问题在于,当我尝试拍摄所有的光目录时,我只得到第一个光目录,另外两个没有。
错误:
代码:
<?php
$yui1 = "SELECT photodirectory FROM photos WHERE photoowner='" . $userid . "'";
$rquery1 = mysqli_query($connDirectory, $yui1);
echo "rquery1 is equal to: ";
var_dump($rquery1);
echo "</br>";
if($fotoutente = mysqli_fetch_row($rquery1)){ //fotoutente = userphoto
for($c = 0; $c < count($fotoutente); $c++){
echo '<img src="../' . $fotoutente["{$c}"] . '">' . "</br>";
}
echo "fotoutente is equal to: ";
var_dump($fotoutente);
}
?>
如果他们的id是1,我怎么能把所有的photodirectory成员带走? 无论如何,上面的PHP代码是用于创建一个包含所有目录的photodirectory的数组,如果等等等...
请救我和加勋爵打败playmysql4。 抱歉英语不好,但我是意大利人......
答案 0 :(得分:0)
通过迭代mysqli_fetch_assoc
循环并在结果中使用<?php
$yui1 = "SELECT photodirectory FROM photos WHERE photoowner= $userid ";
$result = mysqli_query($connDirectory, $yui1);
echo "rquery1 is equal to: ";
var_dump($result);
echo "</br>";
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo '<img src="../' . $row["photodirectory"] . '">' . "</br>";
}
} else {
echo "0 results";
}
?>
来正确重做代码。
这样做:
def resolveA(implicit a: A): String => String = { prefix =>
s"$prefix a=$a"
}
case class A(n: Int)
implicit val a = A(1)
println(resolveA("-->")) // won't compile
答案 1 :(得分:0)
反对SQL注入:
<?php
if (ctype_digit(strval($userid)) === false) {
echo "UserID is not valid!";
exit();
}
$userid_secure = bin2hex($userid);
$rquery1 = mysqli_query($connDirectory, "SELECT photodirectory FROM photos WHERE photoowner=UNHEX('$userid_secure')";
if (mysqli_num_rows($rquery1) > 0) {
while ($fotoutente = mysqli_fetch_assoc($rquery1)) {
echo '<img src="../'.$fotoutente["photodirectory"].'"></br>';
}
} else {
echo "No results";
}
?>