I prefer to use arrays to interact with a mysql database from PHP.
Once you have the tables created, you can do all the logging and editing from the php script
<?php
//First you need to connect
mysql_connect("hostname","username","password");
//Then, select the database you want to use
mysql_select_db("mydatabasename");
//Then the queries. Here's one to add
mysql_query("INSERT INTO tablename ('fieldname1','fieldname2') VALUES ('value1','value2')");
//Or you can gather information. This gets a bit tricky
$query=mysql_query("SELECT * FROM tablename");
while($row=mysql_fetch_row($mysql_query)){
echo($row['fieldname1'] . " is the value of field1. The value of field2 is " . $row['fieldname2'] . "<br>");
}
?>
In that last part, we use the variable $query to store out query, and then we use the while loop to get each row that coem out of the query. This works because we use while($row=mysql_query($query)), and as long as there is more information we haven't seen yet in the query, it returns a value. Once we've gotten all the information, the mysql_fetch_row function will return FALSE, and the while loop will end. So, getting each row one at a time in a loop, we can do whatever we want with the data. Whatever the names of your fields are, you can use in the $row array.
|