hi2all 我有一个表,其中包含 2 个这样的字段
|姓名| 图像 _ | __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _
当用户登录我的网站时,我在会话中注册它的名称,当他上传他的新照片时
我想删除它的旧照片并将他的名字设置为新照片怎么做???
我在数据库中插入每个上传的图像的代码如下我应该添加到我的
$me=$_SESSION['logged-in'];
$con=mysqli_connect("localhost","root","","register_form");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
@mysqli_query($con,"INSERT INTO imgs (name, imags)
VALUES ('$me', '$filename')");
mysqli_close($con);
这是我的代码来展示它
<?php
$me=$_SESSION['logged-in'];
$con=mysqli_connect("localhost","root","","register_form");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT imags FROM imgs where name LIKE '$me' ");
while($row = mysqli_fetch_array($result))
{
$pathimg=$row['imags'];
$d = dir("image");
$entry = $d->read();
/*while (false !== ($entry = $d->read())) {
echo "<li><img src=\"/ConnectMe/html/image/" . $entry . "\">" . $entry . "</li>";
}
*/
}
mysqli_close($con);
echo"
<img width='50' height='60' src=\"/ConnectMe/html/image/$pathimg" . @$entry . "\">
";