Введение в СУБД MySQL


Example.12.3


<?php

$db = mysql_connect("localhost", "root");

mysql_select_db("mydb",$db);

if ($id) {

// query the DB

$sql = "SELECT * FROM employees WHERE id=$id";

$result = mysql_query($sql);

$myrow = mysql_fetch_array($result);

?>

First name:

Last name:

Address:

Position:

<?php

} else {

// display list of employees

$result = mysql_query("SELECT * FROM employees",$db);

while ($myrow = mysql_fetch_array($result)) {

printf("%s %s
\n", $PHP_SELF,

$myrow["id"], $myrow["first"],

$myrow["last"]);

}

}

?>




Начало  Назад  Вперед