Моя проблема: у меня есть таблица sql с "postId" в качестве поля, я пытаюсь "получить" это в URL-адрес, когда пользователь нажимает ссылку
$con = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$result = mysqli_query($con,"SELECT * FROM posts"); //You don't need a ; like you do in SQL
echo "<table border='1'>"; // start a table tag in the HTML
while($row = mysqli_fetch_array($result)){ //Creates a loop to loop through results
echo "<tr><td>" . $row['user'] . "</td><td>" . $row['text'] . "</td><td> <form action="comment.php?= <?=$row['postId'];?>" method="post">
<input type="button" name="submit" value="Comment">
</form> </td></tr>"; //$row['index'] the index here is a field name//$row['index'] the index here is a field name
}
echo "</table>"; //Close the table in HTML
?>
Это мой код, в моей ошибке указано:
Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in /home/content/79/10635579/html/ask/views/logged_in.php on line 24
Хотя я получаю эту ошибку, я, вероятно, форматирую ее неправильно или вообще не делаю ее правильно. Благодарю!
EDIT - ПОЛНЫЙ КОД:
<div>
<!-- if you need user information, just put them into the $_SESSION variable and output them here -->
Hey, <?php echo $_SESSION['user_name']; ?>.
You are logged in.
Try to close this browser tab and open it again. Still logged in! ;)
</div>
<form name="input" action="views/makePost.php" method="get">
Post: <input type="text" name="text">
<input type="submit" value="Submit">
</form>
<?php
require_once("./config/db.php");
$con = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
$result = mysqli_query($con,"SELECT * FROM posts"); //You don't need a ; like you do in SQL
echo "<table border='1'>"; // start a table tag in the HTML
while($row = mysqli_fetch_array($result)){ //Creates a loop to loop through results
echo "<tr><td>" . $row['user'] . "</td><td>" . $row['text'] ."</td><td>
<form action='comment.php?postid=".$row['postId']."' method='post'>
<input type='button' name='submit' value='Comment'>
</form> </td></tr>";
}
echo "</table>"; //Close the table in HTML
?>
<div>
<!-- because people were asking: "index.php?logout" is just my simplified form of "index.php logout=true" -->
<a href="index.php?logout">Logout</a>
</div>
echo "<tr><td>" . $row['user'] . "</td><td>" . $row['text'] ."</td><td>
<form action='comment.php?postid=".$row['postId']."' method='post'>
<input type='submit' name='submit' value='Comment'>
</form> </td></tr>";