Re: [PHP-DB] COUNT() returns 1, but should be 0
On Mon, Dec 22, 2003 at 11:43:35AM +0900, Lew Mark-Andrews wrote: Table structure for cardlist: `visitdate` datetime default NULL, $sql = SELECT COUNT(visitdate) FROM cardlist GROUP BY visitdate; $visitcount = mysql_num_rows($query); echo pTotal number of visits: $visitcount/pbr; // --- Should be zero. I think that there is one visitdate (NULL), so one row is returned. HTH, Tobey Wheelock -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] Retrieve data and column names from a table
On Wed, Dec 17, 2003 at 07:43:50PM -, Shaun wrote: I need to retrieve the data and column names from a single row in a table, i.e. 'SELECT * FROM Table WHERE Field_ID = 1' Maybe something like this: $result = mysql_query (SELECT * FROM Table LIMIT 1,$db); $my_row = mysql_fetch_array ($result, MYSQL_ASSOC); foreach ( $my_row as $key = $value ) { echo $key: $valuebr; } -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP-DB] sql errors?
On Mon, Dec 15, 2003 at 03:49:31PM -0700, Jas wrote: $sql = mysql_query(SELECT hostname FROM $table WHERE vlan = $_POST[dhcp_hosts],$db)or die(mysql_error()); Maybe like this? $sql = mysql_query(SELECT hostname FROM $table WHERE vlan = '. $_POST[dhcp_hosts].',$db)or die(mysql_error()); -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php