这是我的代码,我希望只需点击一下即可打开我的链接。一切正常,它只是,删除,批准ant不批准链接必须双击才能运行它的功能。我希望有人能听到我的声音。
的的index.php 的
<?php
$search = '%';
$fgmembersite->DBLogin();
$limit = 5;
if(isset($_GET['offset'])) {
$offset = mysql_real_escape_string($_GET['offset']);
} else {
$offset = 0;
}
//for namelist a-z
$listname = '%';
If (isset($_GET['namelist']))
{
$listname = $_GET['namelist'];
}
//for search file
if(isset($_POST['searchfile']))
{
$search = $_POST['searchfile'];
}
else if(isset($_GET['searchfile']))
{
$search = $_GET['searchfile'];
}
if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa' OR $_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin')
{
$sql="select * from gmdc_employee where employee_name like '%$search%' AND employee_name like '$listname%' ";
}
else
{
$sql = "select b.* from gmdc_user a, gmdc_employee b where a.username = '".$_SESSION[$fgmembersite->GetLoginSessionVar()]."' and a.company_id = b.company_id AND b.employee_name like '$listname%' AND b.employee_name like '%$search%'";
}
$query = mysql_query("$sql ORDER BY employee_name,confirmation DESC ,file_id DESC,file_date DESC LIMIT $offset,$limit") or die ( mysql_error () );
$result = mysql_query($sql) or die (mysql_error());
$total = mysql_num_rows($result);
if(!$result || mysql_num_rows($result) <= 0)
{
$fgmembersite->HandleError("No file found.");
return false;
}
while ($row = mysql_fetch_assoc($query))
{
$file_id = $row['file_id'];
$file_desc = $row['file_description'];
$file_date = $row['file_date'];
$file_name = $row['file_name'];
$file_accs = $row['folder_access'];
$file_employee = $row['employee_id'];
$file_confir = $row['confirmation'];
$file_ename = ucwords($row['employee_name']);
$info = pathinfo($file_name);
$file_ext = $info['extension'];
echo '<tr>
<td>
</td>
</tr>
<tr class="subone">
<td class="sub" width="100">
'.$file_employee.'
<br />
</td>';
if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa')
{
?><td class="sub" width="100">
<a href="" onclick = javascript:newPopup('addfile.php?emp=<?php echo $file_employee ?>');><?php echo$file_ename?></a>
<br />
</td><?php
}
else
{
echo '<td class="sub" width="182">
'.$file_ename.'
<br />
</td>';
}
echo'<td class="sub" width="218">
<a href="'.$file_accs.$file_name.'" target="_blank" style="text-decoration: underline;">'.$file_desc.'</a>
<br />
</td>
<td class="sub" width="100">
'.date('M d, Y',mktime(0,0,0,substr($file_date,5,2),substr($file_date,8,2),substr($file_date,0,4))).'
<br />
</td>
<td class="sub" width="100">
'.$file_confir.'
<br />
</td>';
if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'sa')
{
if($file_confir == 'Pending' OR $file_confir == 'NotApproved')
{
if(isset($_GET['id']))
{
$fgmembersite->Delete_Db($_GET['id']);
}
echo '<td class="sub" width="100">
<a href="index.php?id='.$file_id.'">Delete</a>
<br />
</td>';
}
}
else if($_SESSION[$fgmembersite->GetLoginSessionVar()] == 'admin')
{
if($file_confir == 'Pending')
{
if(isset($_GET['yes']))
{
$fgmembersite->UpdateYesDB($_GET['yes']);
}
else if(isset($_GET['no']))
{
$fgmembersite->UpdateNoDB($_GET['no']);
}
echo'<td class="sub" width="100">
<a href="index.php?yes='.$file_id.'">Approve</a>
<br /><br />
<a href="index.php?no='.$file_id.'">NotApprove</a>
</td> ';
}
}
}?>
*的 fg_membersite.php *
function Delete_Db($id)
{
$ok = mysql_query("DELETE FROM gmdc_employee WHERE file_id='$id'");
if (!$ok)
{
$this->HandleError("Error deleting profile from database!");
}
}
function UpdateYesDB($fid)
{
$this->DBLogin();
$yes = mysql_query("UPDATE gmdc_employee SET confirmation='Approved' WHERE file_id = '$fid'");
if (!$yes)
{
$this->HandleError("Error updating from database!");
return false;
}
}
function UpdateNoDB($fids)
{
$this->DBLogin();
$no = mysql_query("UPDATE gmdc_employee SET confirmation='NotApproved' WHERE file_id = '$fids'");
if (!$no)
{
$this->HandleError("Error updating from database!");
return false;
}
}
*注意,我只提出删除/批准/不批准功能,因为这是我唯一的问题。感谢
答案 0 :(得分:5)
答案 1 :(得分:1)
如果您能提供该链接的代码会更好。我想知道您是使用Javascript函数还是仅链接从更新转到新页面并删除锚标记。
答案 2 :(得分:1)
请修改以下部分中的引用用法。
echo "<td class='sub' width='100'><a href='index.php?yes=".$file_id."'>Approve</a><br /><br /><a href='index.php?no=".$file_id."'>NotApprove</a></td>";
如果您需要任何澄清,请告诉我。