Guest User

Untitled

a guest
Oct 19th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. <?php
  2.    
  3.     session_start();
  4.     error_reporting(-1);ini_set('display_errors', 1);
  5.     $myServer = "";
  6.     $myUser = "";
  7.     $myPass = "";
  8.     $myDB = "";
  9.     //Connection to the database
  10.     $dbhandle = mysql_connect($myServer, $myUser, $myPass)
  11.     or die("Couldn't connect to SQL Server on $myServer");
  12.     //Select a database to work with
  13.     $selected = mysql_select_db($myDB, $dbhandle)
  14.     or die("Couldn't open database $myDB");
  15. $where = "";   
  16.         if(isset($_GET['id'])){
  17.         $topicID = $_GET['id'];
  18.         $where = " WHERE id = $topicID";
  19.     }    
  20.  
  21.  
  22.  
  23. //Declare the SQL statement that will query the database
  24.     $query = "SELECT * FROM `topics`".$where;
  25.     //Execute the SQL query and return records
  26.     $result = mysql_query($query)
  27.     or die('A error occured: ' . mysql_error());
  28.     //Show result
  29.     while ( $record = mysql_fetch_array($result) )
  30.     {
  31.         echo '<div id="content" align="center">' . '<a href="index.php?id=' . $record["id"] . ' ">'. $record["topic_name"] .'</a>' . " | " .  $record["topic_username"] . " <br><br>" .' </div>';
  32.     }
  33.  
  34.     //Free result set memory
  35.     mysql_free_result($result);
  36.     //Close the connection
  37.     mysql_close($dbhandle);
  38. ?>
  39. <html>
  40.     <head>
  41.     </head>
  42.  
  43.     <body>
  44.     </body>
  45. </html>
Add Comment
Please, Sign In to add comment