Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- error_reporting(-1);ini_set('display_errors', 1);
- $myServer = "";
- $myUser = "";
- $myPass = "";
- $myDB = "";
- //Connection to the database
- $dbhandle = mysql_connect($myServer, $myUser, $myPass)
- or die("Couldn't connect to SQL Server on $myServer");
- //Select a database to work with
- $selected = mysql_select_db($myDB, $dbhandle)
- or die("Couldn't open database $myDB");
- $where = "";
- if(isset($_GET['id'])){
- $topicID = $_GET['id'];
- $where = " WHERE id = $topicID";
- }
- //Declare the SQL statement that will query the database
- $query = "SELECT * FROM `topics`".$where;
- //Execute the SQL query and return records
- $result = mysql_query($query)
- or die('A error occured: ' . mysql_error());
- //Show result
- while ( $record = mysql_fetch_array($result) )
- {
- echo '<div id="content" align="center">' . '<a href="index.php?id=' . $record["id"] . ' ">'. $record["topic_name"] .'</a>' . " | " . $record["topic_username"] . " <br><br>" .' </div>';
- }
- //Free result set memory
- mysql_free_result($result);
- //Close the connection
- mysql_close($dbhandle);
- ?>
- <html>
- <head>
- </head>
- <body>
- </body>
- </html>
Add Comment
Please, Sign In to add comment