Designed By Dotcomwebdesign.com Powered By CMSimple.dk
 

 
WELCOME > sample html page > Sample Page > Student SQL

Student SQL

CREATE TABLE `mawc`.`STUDENTS` (

`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`first_name` VARCHAR( 35 ) NOT NULL ,
`last_name` VARCHAR( 35 ) NOT NULL

) ENGINE = MYISAM ;


 
INSERT INTO `mawc`.`STUDENTS` (`id`, `first_name`, `last_name`) VALUES (NULL, 'Ron', 'Williams'), (NULL, 'Peter', 'Chen'), (NULL, 'D.I. ', 'von Briesen'), (NULL, 'Charlie', 'Spiro'), (NULL, 'Jeff', 'Scott');
 
 

quick query against db...
=====================
 

I'm playin ' with the database...


// connect to server
$con = mysql_connect("localhost", "mawc", "");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}
// connect to db
if (!(mysql_select_db("mawc", $con)))
{
  die('problem with selecting DB:' . mysql_error());
}

$sql = "SELECT * from STUDENTS where first_name = 'Ron'";
// Execute query
$result = mysql_query("SELECT * from STUDENTS");
//echo "

You just executed this query: " . $sql . "

";
//echo "should get " . $result[2];
while($row = mysql_fetch_array($result))
  {
  echo $row['first_name'] . " " . $row['last_name'];
  echo "
";
  }
 

// close the db connection
mysql_close($con);
 
?>