Re: fetch array problems.

From: Date: Thu, 01 Jan 1970 00:00:00 +0000
Subject: Re: fetch array problems.
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7927@lists.php.net to get a copy of this message
Felix: Depending on what you're trying to do try either of these: //Check to see if $color is in DB: $connection = mysql_connect("localhost","user","pass") or die("Died at connection."); $sql = "SELECT * FROM user_prefs WHERE u_id='$UserID'"; $result = mysql_db_query($sql, $connection) or die("Died at query."); $color = mysql_num_rows($result); //If query didn't die, check to see if there is a result for this query: if($color != 0) { echo "<table bgcolor=\".$color['color_1'].\" class=\"nav\">"; } else{ echo "Some error message."; } //Print $color to page: $connection = mysql_connect("localhost","user","pass") or die("Died at connection."); $sql = "SELECT * FROM user_prefs WHERE u_id='$UserID'"; $result = mysql_db_query($sql, $connection) or die("Died at query."); while($row = mysql_fetch_array($result)) { $color = $row['color_1']; echo "<table bgcolor=\"$color\" class=\"nav\">"; } Try that little pup on for size... Russ #-------------------------------------------------------# "Believe nothing - consider everything" Russ Michell Anglia Polytechnic University Webteam http://gertrude.sipu.anglia.ac.uk/webteam r.j.michell@anglia.ac.uk +44 (0)1223 363271 ext 2331 www.theruss.com #-------------------------------------------------------#

« previous php.db (#7927) next »