truckmen wrote [lines edited and re-ordered]:
> I still can't figure it all out.
>
> I am trying to create a web page (using php) where:
>
> 1) A visitor [to the website can view an] address book.
> I have MySQL and PHP available to work with.
After a visit to the manual
<a rel="nofollow" style='text-decoration: none;' href="http://www.php.net/manual" target="_blank">http://www.php.net/manual</a>
<a rel="nofollow" style='text-decoration: none;' href="http://www.php.net/manual/en/tutorial.php" target="_blank">http://www.php.net/manual/en/tutorial.php</a>
<a rel="nofollow" style='text-decoration: none;' href="http://www.php.net/mysql" target="_blank">http://www.php.net/mysql</a>
start with this:
<?php
define('DBHOST', 'localhost');
define('DBUSER', 'nobody');
define('DBPASS', 'password');
define('DBDATA', 'address');
echo '<h1>Address book view</h1>';
echo '<table>';
$conn = mysql_connect(DBHOST, DBUSER, DBPASS)
or die('Cannot connect: ' . mysql_error());
mysql_select_db(DBDATA) or die('Cannot select the DB.');
$sql = "select * from addressbook order by name LIMIT 20";
$res = mysql_query($sql) or die('Query error: ' . nysql_error());
while ($row = mysql_fetch_array($res)) {
echo '<tr>';
foreach ($res as $value) {
echo '<td>', $value, '</td>';
}
echo '</tr>';
}
mysql_free_result($res);
mysql_close($conn);
echo '</table>';
?>
> [The visitor can add addresses to the database]
and this (with an appropriate form):
<?php
$name = $_POST['name'];
$address = $_POST['address'];
$sql = "insert into addressbook (name, address) values('$name', '$address')";
mysql_query($sql) or die('Query error: ' . mysql_error());
?>
> In creating this, I will also need to:
Hey!, start easy
Or there's always the option of a pre-made script and tailoring
it to your needs.
--
Mail to my "From:" address is readable by all at <a rel="nofollow" style='text-decoration: none;' href="http://www.dodgeit.com/" target="_blank">http://www.dodgeit.com/</a>
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" )
may bypass my spam filter. If it does, I may reply from another address!
>> Stay informed about: A user-accessible address book using php?