gpt4 book ai didi

php - 在 PHP 中根据 USER ID 生成自己的页面

转载 作者:可可西里 更新时间:2023-11-01 08:20:49 26 4
gpt4 key购买 nike

对于我的这个查询,我想不出更好的标题。我试图显示所有用户,然后在每一行中都有一个 VIEW 链接(基于他们的用户 ID).. 例如:http://minquep.com/pages/23(其中 23是一个用户的用户标识)...

这也是我的显示功能和删除功能。

我已经使用

在每一行中显示了 VIEW 链接
<a href="<? echo $rows['user_id']?>VIEW</a>

我的问题是,VIEW 链接的每个 url 尚未在 pages 文件夹下生成。

如何根据用户的 user_ids 在每个用户中创建一个 view.php

是否可以在我添加用户时创建一个自动查看页面。以及如何在我的显示功能中调用它

<!-- ALL MEMBERS QUERY -->
<div id="allmembers" class="content">
<?php
include("connection.php"); #DATABASE CONNECTION DO NOT EDIT

#Moderators
$sql="SELECT user_id, special_id, login, user_type, company FROM $tbl_name";
$result=mysql_query($sql);

#count all mods
$count=mysql_num_rows($result);
?>

<br style="clear:both;">

<div style="float:left;margin-left:1%;">
<?php echo "<font size='3px'>There are $count users:</font>"; #OUTPUT COUNT MODS ?>
</div>
<br/><br/>

<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr>
<td>
<form name="form1" method="post" action="" onsubmit="return confirm('Click OK or Cancel to Continue');">
<table width="100%" border="1%" cellpadding="3" cellspacing="1">
<tr>
<td align="center">#</td>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>User Type</strong></td>
<td align="center"><strong>Company</strong></td>
</tr>

<?php
while($rows=mysql_fetch_array($result)){
?>

<tr>
<td align="center"><input name="checkbox[]" type="checkbox" id="checkbox[]" value="<? echo $rows['special_id']; ?>"></td>
<td width="10%"><? echo $rows['special_id']; ?></td>
<td width="25%"><? echo $rows['login']; ?></td>
<td width="20%"><? echo $rows['user_type']; ?></td>
<td><? echo $rows['company']; ?></td>
<td><a href="<?echo $rows['user_id']; ?>">View</a></td>
</tr>

<?php
}
?>

<tr>
<td width="10%" border="0"><input name="delete" type="submit" id="delete" value="Delete Selected User(s)"></td>
</tr>



</table>
</form>
</td>
</tr>

<?php
// Check if delete button active, start this
if($_POST['delete']){
$checkbox=$_POST['checkbox'];
for($i=0;$i<count($checkbox);$i++){
$del_id = $checkbox[$i];
$sql = "DELETE FROM $tbl_name WHERE special_id='$del_id'";
$result = mysql_query($sql);}
// if successful redirect back to manage_users.php
if($result){
echo "<meta http-equiv=\"refresh\" content=\"0;URL=manage_users.php\">"; #REDIRECTION ITSELF
}
}

?>
</table>

最佳答案

你应该看看URL rewriting .为每个用户创建一个物理页面将是疯狂的。

基本上,默认情况下,您会有这样的 URL:http://minquep.com/page.php?user_id=3323

使用 URL 重写,您可以允许人们通过以下 URL 访问 profile.php 页面:http://minquep.com/pages/3323

关于php - 在 PHP 中根据 USER ID 生成自己的页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12035595/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com