2013-07-18 74 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

相關問題