我有一个活动表格供我的会员填写。表格正在运行并转到数据库。
但是,我怎样才能显示哪个成员发布了该活动,以便其他人知道?因为我尝试在sql字符串中使用user_id
并且只显示数据库中的最后一篇帖子而不是所有用户的所有帖子。
这是表格php部分
<?php
include("config/db_connect.php");
include("config/ckh_session.php");
// Inserting user Details code
if (isset($_POST['btnSave'])) {
$event_title = mysqli_real_escape_string($conn, $_POST['event_title']);
$myDate = mysqli_real_escape_string($conn, $_POST['myDate']);
$cboStartTime = mysqli_real_escape_string($conn, $_POST['cboStartTime']);
$dteEndDate = mysqli_real_escape_string($conn, $_POST['dteEndDate']);
$dteEndTime = mysqli_real_escape_string($conn, $_POST['dteEndTime']);
$event_type = mysqli_real_escape_string($conn, $_POST['event_type']);
$country = mysqli_real_escape_string($conn, $_POST['country']);
$event_region = mysqli_real_escape_string($conn, $_POST['event_region']);
$union_territory = mysqli_real_escape_string($conn, $_POST['union_territory']);
$event_town = mysqli_real_escape_string($conn, $_POST['event_town']);
$event_postalcode = mysqli_real_escape_string($conn, $_POST['event_postalcode']);
$event_title = mysqli_real_escape_string($conn, $_POST['event_title']);
$event_description = mysqli_real_escape_string($conn, $_POST['event_description']);
$event_ltm = mysqli_real_escape_string($conn, $_POST['event_ltm']);
$insert = mysqli_query($conn, "update events set event_title = '" . $event_title . "' ,
myDate = '" . $myDate . "' ,
cboStartTime = '" . $cboStartTime . "' ,
dteEndDate = '" . $dteEndDate . "' ,
dteEndTime = '" . $dteEndTime . "' ,
event_type = '" . $event_type . "' ,
country = '" . $country . "' ,
event_region = '" . $event_region . "' ,
union_territory = '" . $union_territory . "' ,
event_town = '" . $event_town . "' ,
event_postalcode = '" . $event_postalcode . "' ,
event_title = '" . $event_title . "' ,
event_description = '" . $event_description . "' ,
event_ltm = '" . $event_ltm . "' ") or die(mysqli_error($conn));
if ($_POST['event_ltm'] == 'MF Cpl') {
header("location: CoupleffEvent.php");
} else if ($_POST['event_ltm'] == 'MM Cpl') {
header("location: CouplemmEvent.php");
} else if ($_POST['event_ltm'] == 'FF Cpl') {
header("location: CoupleffEvent.php");
}
}
// Fetch user details
$query = mysqli_query($conn, "select * from user where user_id = '" . $_SESSION['last_id'] . "' ");
$fetch_user = mysqli_fetch_array($query);
$user_country = $fetch_user['user_country'];
$user_gender = $fetch_user['user_gender'];
?>
任何帮助都会非常感激,所以我可以进入下一步
答案 0 :(得分:0)
我不确定你要了解的是什么。 如果您正在获取user_id,则必须选择* FROM events然后加入用户表,例如INNER JOIN用户ON events.user_id = user.id
此类请求将显示有关user.id
的所有事件和联接信息资源:https://www.w3resource.com/mysql/advance-query-in-mysql/inner-join-with-multiple-tables.php
希望它会有所帮助,