Advertisement
Guest User

Untitled

a guest
Mar 30th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. <?php
  2. $servername = "localhost";
  3. $username = "username";
  4. $password = "";
  5. $dbname = "dbname";
  6.  
  7. // Create connection
  8. $conn = new mysqli($servername, $username, $password, $dbname);
  9. // Check connection
  10. if ($conn->connect_error) {
  11. die("Connection failed: " . $conn->connect_error);
  12. }
  13.  
  14. $sql = "SELECT comment_txt, name, comment_date FROM mytablename where productcomment_increment_id='$productId' && comment_status='Approved'";
  15. $result = $conn->query($sql);
  16.  
  17. if ($result->num_rows > 0) {
  18. while($row = $result->fetch_assoc()) {
  19. echo "<i><b>Author Name:</b></i>";
  20. echo $row["name"];
  21. echo "<br /><i><b> Comment: </i></b>";
  22. echo $row["comment_txt"];
  23. echo "<br /><i><b>Date: </i></b>";
  24. echo $row["comment_date"];
  25. echo "<br><br>";
  26. }
  27. } else {
  28. //echo "0 results";
  29. }
  30. $conn->close();
  31. ?>
  32.  
  33. //database read adapter
  34.  
  35. $read = Mage::getSingleton('core/resource')->getConnection('core_read');
  36.  
  37. $results = $read->fetchAll("select * from your_tablename");
  38. foreach($results as $row)
  39. {
  40. echo "<i><b>Author Name:</b></i>";
  41. echo $row["name"];
  42. echo "<br /><i><b> Comment: </i></b>";
  43. echo $row["comment_txt"];
  44. echo "<br /><i><b>Date: </i></b>";
  45. echo $row["comment_date"];
  46. echo "<br><br>";
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement