Guest User

Untitled

a guest
Oct 19th, 2018
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.43 KB | None | 0 0
  1. <?php
  2.    
  3.     session_start();
  4.     error_reporting(-1);ini_set('display_errors', 1);
  5.     $myServer = "mysql8.000webhost.com";
  6.     $myUser = "a1761169_chat";
  7.     $myPass = "site123";
  8.     $myDB = "a1761169_chat";
  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.         $id = $_GET['id'];
  18.         $where = " WHERE id = $id";
  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.         if(isset($_GET['id'])){ echo $record['topic_input']; }
  32.         echo '<div id="content" align="center">' . '<a href="index.php?id=' . $record["id"] . ' ">'. $record["topic_name"] .'</a>' . "<br><br>" . '<table style="word-wrap:break-word;table-layout:fixed;" width="600px" border="1"><tr><td>'.$record['topic_input'].'</td></tr></table>' . '</div>';
  33.     }
  34.  
  35.  
  36.     //Free result set memory
  37.     mysql_free_result($result);
  38.     //Close the connection
  39.     mysql_close($dbhandle);
  40. ?>
  41. <html>
  42.     <head>
  43.     </head>
  44.  
  45.     <body>
  46.     </body>
  47. </html>
Add Comment
Please, Sign In to add comment