1 回答
TA贡献1830条经验 获得超3个赞
我认为你只是有一些语法错误。
<?php
session_start();
include 'sqlconnection.php';
$conn = OpenCon();
$stmt = $conn->prepare('SELECT uid,coverphoto,profilepic,bio FROM profile WHERE uid = ?');
$stmt->bind_param('i', $_SESSION['uid']);
$result = $stmt->execute();
if ($result){
if ($result['coverphoto']){
$coverphoto = 'coverphoto.jpg';
}else{
if ($result['profilepic']){
$profilepic = "profilepic.jpg";
}else{
$stmt->bind_result($uid,$coverphoto,$profilepic,$bio);
while($stmt->fetch()) {
$output=array(
'uid' => $uid,
'coverphoto' => $coverphoto,
'profilepic' => $profilepic,
'bio' => $bio
);
}
}
}
}
$json=json_encode($output);
echo $json;
$stmt->close();
CloseCon($conn);
?>
你也可以这样做
<?php
<?php
session_start();
include 'sqlconnection.php';
$conn = OpenCon();
$stmt = $conn->prepare('SELECT uid,coverphoto,profilepic,bio FROM profile WHERE uid = ?');
$stmt->bind_param('i', $_SESSION['uid']);
$stmt->execute();
$stmt->bind_result($uid,$coverphoto,$profilepic,$bio);
while($stmt->fetch()) {
$output=array(
'uid' => $uid,
'coverphoto' => $coverphoto ? $coverphio : 'coverphoto.jpg',
'profilepic' => $profilepic ? $profilepic : 'profilepic.jpg',
'bio' => $bio
);
}
$json=json_encode($output);
echo $json;
$stmt->close();
CloseCon($conn);
?>
- 1 回答
- 0 关注
- 74 浏览
添加回答
举报