Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $username = "root";
- $password = "";
- $hostname = "localhost";
- if(isset($_GET['id'])){
- $id = $_GET['id'];
- }else{
- $id = 0;
- }
- //connection to the database
- $dbhandle = mysql_connect($hostname, $username, $password)
- or die("Unable to connect to MySQL");
- //select a database to work with
- $selected = mysql_select_db("examples",$dbhandle)
- or die("Could not select examples");
- //execute the SQL query and return records
- $result = mysql_query("SELECT name FROM cars where id ='$id'");
- //fetch tha data from the database
- while ($row = mysql_fetch_array($result)) {
- echo "Cars is: ".$row{'name'};
- }
- //close the connection
- mysql_close($dbhandle);
- ?>
Add Comment
Please, Sign In to add comment