2013-07-18 106 views
1
<?php 

session_start(); 

if (!isset($_SESSION['username'])) { 
header('Location: LoginForm.php'); 
} 

?> 

<html> 


<head> 

<meta http-equiv="content-type" content="text/html; charset=utf-8" /> 
<title>Secured Page</title> 

<style> 
.db-table {position:absolute;top:95px;left:300px;} 
</style> 

</head> 
<body> 

<p align="left" style="margin-left:0px; margin-top:135px;">   
<form action="Secured_Page_Search.php" method="post"> 
Select_Table_To_Display:<br><select name="Table"> 
<option value="members">Members</option> 
<option value="online">Online</option> 
<input type="submit" name="submit_name" /> 

      </form> 

<title>Secured Page</title> 
<style type="text/css"> 
body{font-family:Impact;}          
#container{width:10000px;margin:auto;font-size:15pt;} 

#menu{position:absolute;margin-top:10px;} 
#menu ul .item{display:none;} 
#menu ul:hover .item{display:block;background:#white;padding:1px;margin:1px;} 

#menu ul:hover .item a{color:#abc;text-decoration:none;} 
#menu ul:hover .item a:hover{color:grey;} 

#menu ul{width:110px;float:left;margin:0px;padding:2px;background:white;list- 

Style:none;} 
.clear{clear:both;height:10px;} 
</style> 


<div id="container"> 
<h1></h1> 

<div id="menu"> 

<p align="left" style="margin-left:0px; margin-top: 0px;"> 
<br><FONT FACE="arial">Logged In @: (<?php echo $_SESSION['username']; ?>)</FONT></p> 
</p> 

<ul id="item1"> 
<li class="top">Profile</li> 
<li class="item"><a href="#">Profile User</a></li> 
<li class="item"><a href="#">Profile I.M.</li> 
<li class="item"><a href="#">Profile O.P.</a></li> 
</ul> 

<ul id="item1"> 
<li class="top">Edit</li> 
<li class="item"><a href="#">Edit User</a></li> 
<li class="item"><a href="#">Edit I.M.</li> 
<li class="item"><a href="#">Edit O.P.</a></li> 
</ul> 

</div> 
<div class="clear"></div> 

</body> 


<br><FONT FACE="arial"> 


<?php 

$Table = 'members'; 

$mysqli = new mysqli("XXXXXXXX", "XXXXXXXX", "XXXXXXXX", "XXXXXXXXXX"); 
$result = $mysqli->query("SHOW TABLES"); 
while ($row = $result->fetch_row()){ 
$table = $row[0]; 
$result1 = $mysqli->query("SELECT * FROM $Table ORDER BY dt DESC LIMIT 0,12"); 
if($result1) { 
echo '<table cellpadding="15" cellspacing="20" class="db-table">'; 
$column = $mysqli->query("SHOW COLUMNS FROM $Table");echo '<tr>'; 
while($row3 = $column->fetch_row()) { 
echo '<th>'.$row3[0].'</th>'; 
} 
echo '</tr>'; 
while($row2 = $result1->fetch_row()) { 
echo '<tr>'; 
foreach($row2 as $key=>$value) { 
LINE 110 ----> echo '<td style="padding-top:0px;padding-bottom:0px;">',$value,' 
<a href="edit.php?id=<?' echo $row['id']; '?>">'Edit'</a></td>;'<------Line 110 
    } 
    echo '</tr>'; 
} 
echo '</table><br />'; 
} 
} 
$mysqli->close(); 

?> 

<FONT FACE="impact"> 

<p align="left" style="margin-left:100px; margin-top:100PX;"> 

<form action="Secured_Page_Search_Email.php" method="post"> 
Search, Email:<br>        <input type="text" name="email"><br> 
    <input type="submit" name="submit_name" /> 
      </form> 

<p align="left" style="margin-left:100px; margin-top:10px;">  


<form action="Secured_Page_Search_User.php" method="post"> 
Search, User:<br>      <input type="text" name="usr"><br> 
    <input type="submit" name="submit_name" /> 
      </form>    

</FONT></p> 
</body> 
</html> 

基本上我需要mysql表格来打印一个编辑链接......看起来很容易,但在过去的几个小时里一直在与这个问题作斗争。有问题的行:语法错误,意外的T_ECHO,期待','或';'在/Secured_Page_Edit.php在线110

基本上我需要mysql表格来打印一个编辑链接......看起来很容易,但在过去的几个小时里一直在与这个问题作斗争。有一个问题行:

LINE 110 ----> echo '<td style="padding-top:0px;padding-bottom:0px;">',$value,' 
<a href="edit.php?id=<?' echo $row['id']; '?>">'Edit'</a></td>;'<------Line 110 

更新的代码更新的代码

echo '<td><a href="edit.php?id='.$row['id'].'">'Edit'</a></td>;' 

解析错误:语法错误,意想不到的T_ECHO,期待 '' 或 ';'在线113上的Secured_Page_Edit.php

回答

3
echo '<td style="padding-top:0px;padding-bottom:0px;">'.$value.' 
<a href="edit.php?id='.$row['id'].'">Edit</a></td>'; 
+0

好价钱!!!谢谢 – Philcinbox

1

您的php打开/关闭标记是什么被回显的一部分。以及使用逗号而不是点(。)来追加$value。但是,在PHP中已经构建字符串时,没有任何理由需要回显html字符串。

echo '<td style="padding-top:0px;padding-bottom:0px;">',$value,'<a href="edit.php?id=<?' echo $row['id']; '?>">'Edit'</a></td>;' 

我想你想:

echo '<td style="padding-top:0px;padding-bottom:0px;">'.$value.'<a href="edit.php?id='.$row['id'].'">Edit</a></td>;' 
// Changes are:          ^  ^   ^    ^

UPDATE(感谢弗雷德)可以在实际上使用逗号在回波通话追加一个字符串。所以这也是有效的:

echo '<td style="padding-top:0px;padding-bottom:0px;">', $value, '<a href="edit.php?id=', $row['id'], '">Edit</a></td>;' 
+0

逗号在回声中很好:echo使用任意数量的参数,并将它们连接在一起。 'echo'a','b';'和'echo'a'。'b';'产生相同的输出。 –

+0

哇,永远不会知道。对我来说,似乎是一种幻觉。如果你打算提供更多的参数,我希望不得不把它包装在不合格的产品中。每天学些新东西。感谢您的提示 – immulatin

+0

感谢所有的答复!问题关闭 – Philcinbox

2

你连接文本和变量的方式是错误的。见http://php.net/manual/en/language.operators.string.php

你应该写这样的事:

LINE 110 ----> echo '<td style="padding-top:0px;padding-bottom:0px;">' . $value . ' 
<a href="edit.php?id='. $row['id'] .'">Edit</a></td>;'<------Line 110 

更确切地说,混合点和逗号是好的,但如果使用单引号与回声,你应该确保把任何一个点或(如果你想继续你的字符串[1])或者分号,如果你完成[2]。

echo 'Text and '.$variable; // [1] 
echo $variable.' and text'; // [2] 

另请参阅http://us.php.net/manual/en/function.echo.php

相关问题