Re: PHP5 is coming out!!!

From: Date: Tue, 01 May 2001 12:29:18 +0000
Subject: Re: PHP5 is coming out!!!
Groups: php.db 
Request: Send a blank email to php-db+get-9020@lists.php.net to get a copy of this message
Hiya, > what's wrong with the following script - > > <?php > > if (empty($hidden)) { > displayform(); > exit; > } > > $site= 'db.alphabot.f2s.com'; > $usernames = 'alphabot'; > $passwords = 'money'; > $dbName = 'alphabot'; > $connect = mysql_connect($site,$usernames,$passwords); > mysql_select_db($dbName,$connect); > $result = mysql_query("SELECT ID, rank, description FROM sites WHERE description LIKE '%$query%' ",$connect); > echo $result; <<<<<<<<< This is the problem. $result is just a pointer to the MySQL results form the query. You must do something like: -------start--------- ?> <table width=100%> <tr> <td>ID</td> <td>rank</td> <td>description</td> </tr> while ($row = mysql_fetch_row($result) { echo " <tr>\n <td>$row[0]</td>\n <td>$row[1]</td>\n <td>$row[2]</td>\n </tr>\n"; } echo "</table>"; --------end---------- That's will print out the values for your query. Note: I haven't checked the HTML or code. This should give you a starting point though. > function displayform() { > global $PHP_SELF; > ?> > <form method="GET" action="<?php echo $php_self;?>"> > <input type="text" size="20" name="query"> > <input type="hidden" name="hidden" value="true"> > <input type="hidden" name="shown" value="0"> > <input type="submit" name="B1" value="Submit"><br> > <table cellpadding="0" cellspacing="0" border="0"> > <td><input type=radio name=all checked value=no></td> > <td><font face="Arial" size="1">Any Of the > words</font></td> > <td><input type=radio name=all value=yes></td> > <td><font face="Arial" size="1">All Of The > Words</font></td> > </form> > <?php > } > ?> Good Luck! Jonathan Wright..

« previous php.db (#9020) next »