0

I am trying to print text I have placed into a MySql database. I have been able to insert into the database, but I don't know what to put to take out the value/text

<?php

  require("../includes/config.php");

  if($_SERVER["REQUEST_METHOD"] == "POST")
  {
  $query = CS50::query("INSERT INTO posts (post_content) VALUES (?)", $_POST["comment"]);

  $comment = CS50::query("SELECT * FROM posts WHERE post_content = ?", $_POST["comm"]);

  echo('<div class="container">');
  echo('<ul class="media-list forum" style = "padding: 20px 0px 20px 0px;">');
  echo('<li class="media well">');
  echo('<div class="pull-left user-info" href="#">');
  echo('<img src="img/merylface.png" width="64" alt="Everyone is Meryl">');
  echo('<div>');
  echo('<strong>Anonymous</strong>');
  echo('</div>');
  echo('</div>');
  echo('<div class="media-body">');
  echo($comment);
  echo('</div>');
  echo('</li>');
  echo('</ul>');
  echo('</div>');
  }
?>  

1 Answer 1

1

recall that, assuming the query is syntactically correct, query returns an array of the resulting rows (if any) or an empty array otherwise. try print_r'ing $comment to learn about the structure of the contents!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .