first script

From: Date: Fri, 20 Apr 2007 19:05:06 +0000
Subject: first script
Groups: php.general 
Request: Send a blank email to php-general+get-253378@lists.php.net to get a copy of this message
adapted from php/mysql for dummies, I'd like it to return the "notes" field, too, pls. I know that I want to echo "notes", but can't figure out where to do so. any pointers would be appreciated :) [thufir@localhost ~]$ [thufir@localhost ~]$ [thufir@localhost ~]$ cat /var/www/html/showapts.php <html> <head><title>apts</title></head> <body> <?php $user="root"; $host="localhost"; $password="password"; $database = "apts"; $connection = mysql_connect($host,$user,$password) or die ("couldn't connect to server"); $db = mysql_select_db($database,$connection) or die ("Couldn't select database"); $query = "SELECT DISTINCT * FROM craigslist ORDER BY id"; $result = mysql_query($query) or die ("Couldn't execute query."); /* create form containing selection list */ echo "<form action='processform.php' method='post'> <select name='id'>\n"; while ($row = mysql_fetch_array($result)) { extract($row); echo "<option value='$id'>$id\n"; } echo "</select>\n"; echo "<input type='submit' value='id'> </form>\n"; ?> </body> </html> [thufir@localhost ~]$ [thufir@localhost ~]$ mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 98 to server version: 5.0.27 Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | apts | | mysql | | test | +--------------------+ 4 rows in set (0.00 sec) mysql> use apts; Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +----------------+ | Tables_in_apts | +----------------+ | craigslist | +----------------+ 1 row in set (0.00 sec) mysql> describe craigslist; +-------+---------------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+---------------------+------+-----+---------+-------+ | notes | longtext | NO | | | | | id | bigint(15) unsigned | NO | | | | +-------+---------------------+------+-----+---------+-------+ 2 rows in set (0.01 sec) mysql> quit Bye [thufir@localhost ~]$ [thufir@localhost ~]$ date Fri Apr 20 19:40:29 BST 2007 [thufir@localhost ~]$ [thufir@localhost ~]$ thanks, Thufir

« previous php.general (#253378) next »