RE: [PHP] What am I doing wrong - PHP

From: Date: Fri, 12 Nov 2004 21:06:27 +0000
Subject: RE: [PHP] What am I doing wrong - PHP
Groups: php.general 
Request: Send a blank email to php-general+get-201873@lists.php.net to get a copy of this message
Stuart Felenstein <mailto:stuart4m@yahoo.com> on Friday, November 12, 2004 12:54 PM said: > //This is my call to the table "staindtypes" > <?php > mysql_select_db($database_lokale, $lokale); > $indque1 = "SELECT * FROM staindtypes"; > $inds = mysql_query($indque1, $lokale) or > die(mysql_error()); > $row_inds = mysql_fetch_assoc($inds); > $totalRows_inds = mysql_num_rows($inds); > $row = mysql_fetch_row; > $rows = mysql_num_rows($inds); > if($rows > 0) { > mysql_data_seek($inds, 0); > $rows = mysql_fetch_assoc($inds); > } >> > > When I load the page it is blank. > > Any help would be appreciated. Well your code is a bit hard to follow (imo) but I notice that you have: $row_inds = mysql_fetch_assoc($inds); but then never refer to $row_inds again. I would do the following: <?php $row_inds = mysql_fetch_assoc($inds); $row_inds_cnt = count($row_inds); echo "<select ...>\n"; if($row_inds_cnt > 0) { for($i = 0; $i < $row_inds_cnt; $i++) { echo " <option value=\"...\">...</option>\n"; } } else { echo " <option value=\"empty\">empty</option>\n"; } echo "</select>\n"; ?> hth, Chris.

« previous php.general (#201873) next »