php @ mysql help [duplicate]
开发者_JAVA百科Possible Duplicate:
Extremely basic PHP and Mysql
i am new to web scripting languages. i want to know what are the function's and theories i need to know if i want to submit & retrieve data using php @ mysql...\
ex;- user submits a phone of a picture with details,user can search them ...likewise
You may take a look at many tutorials freely available on the net. For example:
http://www.freewebmasterhelp.com/tutorials/phpmysql - describes it in fine details.
first of all to work with mysql in php you need to have a basic understanding of SQL commands like SELECT,INSERT,DELETE... which can be found all over the web.
then you must use the mysql related functions in php to actually execute those commands.
you can find the manual in http://php.net/manual/en/book.mysql.php.
Before you can make any queries, you have to connect to the correct database!
$link = mysql_connect('localhost', 'db_user', 'db_pass');
mysql_select_db('db_database',$link));
Please replace DB_USER and DB_PASS with your login info and the DB_DATABASE witht he corresponding database.
Here's some basic queries:
database table (table):
name text
Here's some code:
mysql_query("INSERT INTO table (name, text) VALUES ('Yo', 'hello')");
This will put a new entry of "yo" and "hello" into the database table (table).
And if you want to display a table, you can do something like this:
$result = mysql_query("SELECT * FROM table");
while($row = mysql_fetch_array($result)) {
echo $row['name'] . " - " . $row['text'];
echo "<br />";
}
Now this is by far a very simple explanation. There are tons of resources on the internet you can look at.
Have fun! (but not too much)
w3school.com has some great examples and easy to understand MYSQL explanations.
精彩评论