ok, the begining....
PHP:
php files must start with <?PHP or <? lines are terminated by ; unless a { is there
to connect to MYSQL through PHP, use this code:
$connect = mysql_connect("localhost", "databaseusername", "databasepassword");//connects to the database
$select = mysql_select_db("databasename"); //selects the database
$connect is now a short name for mysql_connect("localhost", "databaseusername", "databasepassword");
and $select is a short name for mysql_select_db("databasename"); . They may not need to be used that often, but some query's may need to use them from time to time.
Next, query's:
After typing the connect code add this code below mysql_select_db... :
$query = mysql_query("SELECT * FROM databasetable"); //selects where the data is coming from in the table.
Now, if you want to display data from the database on a page you use:
while ($row = mysql_fetch_array($query)) {
$get1 = $row["get1"];
$get2 = $row["get2"];
$get3 = $row["get3"];
//and so on.
now to display the data it has to be echo'd through php. So add:
echo"$get1";
echo"$get2"; //html can be added here, but errors will emerge if there are " (quotes) in the code, you can avoid the errors by adding a in from of the " so for example <td height="20"> looks like this <td heigh="20">
echo"$get3";
//and so on.
now that this data has been set to echo you can close this by adding a } at the end.
now close the code with ?>
Fullcode:
<?PHP
$connect = mysql_connect("localhost", "databaseusername", "databasepassword");
$select = mysql_select_db("databasename");
$query = mysql_query("SELECT * FROM databasetable");
while ($row = mysql_fetch_array($query)) {
$get1 = $row["get1"];
$get2 = $row["get2"];
$get3 = $row["get3"];
echo"$get1";
echo"$get2";
echo"$get3";
}
?>
Right, who's still awake? ok rephrase... Who is still awake and understood a word of that?
Let me know what u are having trouble with and ill explain it more indepth.
Corky