Advertisement
Guest User

Untitled

a guest
Jan 4th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. <?php
  2. if(!empty($_GET['id'])){
  3. //DB details
  4. $host="localhost";
  5. $db_user ="root";
  6. $db_password="";
  7. $db_name="exampledatabase";
  8.  
  9. //Create connection and select DB
  10. $connection= @new mysqli($host, $db_user, $db_password, $db_name);
  11.  
  12. if ($connection->connect_error) {
  13. die("Unable to connect database: " . $connection->connect_error);
  14. }
  15.  
  16. //get content from database
  17. $query = $connection->query("SELECT * FROM cms_content WHERE id = {$_GET['id']}");
  18.  
  19. if($query->num_rows > 0){
  20. $cmsData = $query->fetch_assoc();
  21. echo '<h4>'.$cmsData['title'].'</h4>';
  22. echo '<p>'.$cmsData['content'].'</p>';
  23. echo '<p>'.$cmsData['price'].'</p>';
  24. echo '<p>'.$cmsData['id'].'</p>';
  25. }else{
  26. echo 'Content not found....';
  27. }
  28. }else{
  29. echo 'Content not found....';
  30. }
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement