Hi all,

I am having 5 rows in a mysql database related to five
different users. these rows contains their firstname,
lastname and details of scenes 1 to 5(these details
are numeric values from 1 to 3). if any of these
fields from scenes 1 to 5 are empty that will be
detected from the firstname of the user(collected from
a form with a filed name 'fname') by opening the
database and will be indicated to that user from which
scene he got empty fields. here is the code that i
wrote works like a champ.

$db = mysql_connect ("localhost","myname","password")
or die("<b>Unable to connect to database.</b>");
mysql_select_db ("nimitztest",$db) or die("<b>Unable
to select database.</b>");
$result = mysql_query ("select * from mytable order by
id",$db);
if ($row=mysql_fetch_array($result))
{
while ($row=mysql_fetch_array($result))
{
$FirstName = $row["firstname"];
if ($fname == $FirstName) 
{
for ($i=1; $i<=5; $i++)
  {
  $Num[$i] = $row["num$i"];
  if ($Num[$i] == '') {
  printf ("You have to goto Scene$i<p>"); 
  break;
   }
  } 
}
}
}

But when i include the else statement like below, to
indicate an user with all the fields filled up as 'You
don't have any thing to fill', this code is giving
weird results such as printing like this onto the
screen:

You don't have anything to fill
You have to goto Scene2
You have to goto Scene3
You have to goto Scene4
You have to goto Scene5

for a user with scene2 onwards empty fields.
This may be, because of fault in my code or because of
misinterpretation of the mysql functions by me. 

---------
for ($i=1; $i<=5; $i++)
{
  $Num[$i] = $row["num$i"];
  if ($Num[$i] == '') {
  printf ("You have to goto Scene$i<p>");
  }
  else {
  printf ("You don't have anything to fill<p>");
  }
}
----------

Please correct me about the mistake i am making over
above.

TIA
Chakravarthy K Sannedhi



__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - Buy the things you want at great prices. 
http://auctions.yahoo.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to