Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can you tell me what functions to use

Status
Not open for further replies.

rosesau

Programmer
May 24, 2001
9
AU
Hi,

i need some help with mysql. i need to do the following from a php web page, can anyone tell me what to use and how.

update data in a table
insert data in a table
delete data in a table
create a table
and how to check to see if a database exists or not.

any help would be great.

thanks

rose
 
Okay,

let's do a short example combining everything:

<?php

//CONNECTING TO MYSQL AND SELECTING THE RIGHT DATABASE
mysql_connect(&quot;localhost&quot;,&quot;username&quot;,&quot;password&quot;);
$db = mysql_select_db(&quot;databaseName&quot;);

//CHECKING IF THE DB EXISTS
if($db) print(&quot;Database exists!&quot;);

//CREATE THE TABLE
mysql_query(&quot;CREATE TABLE testtable (col1 int,col2 int)&quot;);

//INSERT SOMETHING IN THE TABLE
mysql_query(&quot;INSERT INTO testtable (col1,col2) VALUES (1,2)&quot;);

//UPDATE THE DATA IN THE TABLE
mysql_query(&quot;UPDATE testtable SET col2=3&quot;);

//DELETE A ROW FROM THE TABLE
mysql_query(&quot;DELETE FROM testtable WHERE col1=1&quot;);
?>

For more details, visit
Hope this helps you finding your way again :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top