Retrieving Data With PHP & MySQL(while loop)

<?php
mysql_connect(“localhost”, “admin”, “password”) or die(mysql_error());
mysql_select_db(“test”) or die(mysql_error());

// Retrieve all the data from the “example” table
$result = mysql_query(“select * from example”) or die(mysql_error());

//store the record of the “example” table into $row

//Print out the contents of the entry
echo “<table border=’1′>”;
echo “<tr><th>Name</th><th>Age</th></tr>”;
while($row = mysql_fetch_array($result))
{
echo “<tr><td>”.$row[‘name’].”</td><td>”.$row[‘age’];
echo “</td></tr>”;
}
echo “</table>”;
?>

Advertisements

insert data into your working databases

<?php
mysql_connect(“localhost”, “admin”, “password”) or die(mysql_error());
mysql_select_db(“test”) or die(mysql_error());

mysql_query(“insert into example(name,age) values(‘Timmy Smith’,’23’)”) or die(mysql_error());
mysql_query(“insert into example(name,age) values(‘Rachel Wang’,’23’)”) or die(mysql_error());
mysql_query(“insert into example(name,age) values(‘Timmy wallace’,’23’)”) or die(mysql_error());

echo “Data Inserted!”;
?>

use session create member log in wih mysql–continue

then you should create your logout.php

here is the code:

<?php
  session_start();
 
  // store to test if they *were* logged in
  $old_user = $_SESSION[‘valid_user’];  
  unset($_SESSION[‘valid_user’]);
  session_destroy();
?>
<html>
<body>
<h1>Log out</h1>
<?php
  if (!empty($old_user))
  {
    echo ‘Logged out.<br />’;
  }
  else
  {
    // if they weren’t logged in but came to this page somehow
    echo ‘You were not logged in, and so have not been logged out.<br />’;
  }
?>
<a href=”authmain.php”>Back to main page</a>
</body>
</html>