Database name : db1
Username : dbuser
Password : dbpwd
PHP Code
}
-----------CREATE TABLE-----------------
<?
$db="db1"; $userName="dbuser";
$password="dbpwd";
$hostName="localhost";
$c=mysql_connect($hostName,$userName,$password);
$stmt="create table testtable(name varchar(20))";
mysql_select_db($db);
if(mysql_query($stmt)) { echo"Table createdsuccessfully"; }else {echo"error";
}< BR>
?>
------------INSERT INTO TABLE-----------------
<?
$db="db1";
$userName="dbuser";
$password="dbpwd";
$hostName="localhost";
$c=mysql_connect($hostName,$userName,$password);
$stmt="insert into testtable values ('value3')";
mysql_select_db($db); if(mysql_query($stmt)) { echo"Value
insertedsuccessfully"; }else {echo"error"; }? >
?>
----------------SELECT FROM TABLE-----------------
< ?
$db="db1";
$userName="dbuser";
$password="dbpwd";
$hostName="localhost";
$c = mysql_connect($hostName,$userName,$password);< BR> $stmt="select
*from testtable";
<BR>
mysql_select_db($db); if($result=mysql_query($stmt)) { while($row=mysql_fetch_object($result))
{ echo "
"; echo $row->name; } } else {echo "error"; } < BR>
?> |