我想链接到具有上传者名称的上传者列的表。
<a href="?uploader=MM_Username" class="login"><?php echo $_SESSION['MM_Username'];?></a>
<?php
$subQ2 = '';
if(isset($_GET['uploader']) && $_GET['uploader']!='')
{
$subQ2 = ' WHERE uploader="'.mysql_real_escape_string(str_replace('_', '', $_GET['uploader'])).'"';
}
function uploader()
{
if(isset($_GET['uploader']) && $_GET['uploader']!='')
{
return $_GET['uploader'];
}
else return "uploader";
}
$query_Form = "SELECT * FROM docus".$subQ2.' ORDER BY ID DESC';
$Form = mysql_query($query_Form, $dbconnection) or die(mysql_error());
$row_Form = mysql_fetch_assoc($Form);
$totalRows_Form = mysql_num_rows($Form);
?>
我正在尝试从视频教程中学习php和sql,所以这可能听起来像一个愚蠢的问题。
任何帮助都是非常苛刻的
答案 0 :(得分:0)
试试此代码
<?php
function uploader()
{
global $dbconnection;
$return = array('data' => null, 'data_count' => 0);
if(!empty($_GET['uploader']))
{
$data = mysql_real_escape_string(str_replace('_', '', $_GET['uploader']));
$query_Form = 'SELECT * FROM docus WHERE uploader="'.trim($data).'" ORDER BY ID DESC';
$Form = mysql_query($query_Form, $dbconnection) or die(mysql_error());
$return['data'] = mysql_fetch_assoc($Form);
$return['data_count'] = mysql_num_rows($Form);
}
return $return;
}
$total = upload();
// $row_Form - is now $total['data];
// $totalRows_Form - is now $total['data_count];
?>