RE: What am I doing wrong - PHP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Stuart Felenstein <mailto:stuart4m@xxxxxxxxx>
    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.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux