简体   繁体   中英

Form issues sending an id to a new page for $_GET

Having trouble getting the $row['post_topic'] to actually pass the id over to reply page. If I input an ID manually, for example '2', it works absolutely fine.

echo '<form method="post" action="reply.php?id=' .$row['post_topic']. '">
          <textarea name="reply-content"></textarea>
          <input type="submit" value="Replyy" />
      </form>';

Edit

An extra note, echo $row['post_topic']; works inside one of the While loops I have in the same file.

Query:

$sql= "SELECT 
           posts.post_topic,
           posts.post_content,
           posts.post_date,
           posts.post_by,
           users.user_id,
           users.user_name
       FROM
           posts
       LEFT JOIN
           users
       ON
           posts.post_by = users.user_id
       WHERE
           posts.post_topic = 
              '" .mysqli_real_escape_string($connect, $_GET['id']). "'";

PHP:

$row = $resultpost->fetch_assoc();

echo $row['post_topic'];

echo '<br><table border="0"';
  echo '<tr>';
    echo '<th>';
      echo '<form method="post" action="reply.php?id='.$row['post_topic']. '">
                 <textarea name="reply-content"></textarea>
                 <input type="submit" value="Reply" />
            </form>';
    echo '</th>';
  echo '</tr>';

Check the data type using gettype($row['post_topic']) . This may be the issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM