One correction, Ricardo
for appending the rows, you will have to change the condition
Advertising
//for 1st row
if($valueChk >= 1 && $valueChk <= 3)
//for 2nd row
if($valueChk >= 2 && $valueChk <= 3)
//for 3rd row
if($valueChk == 3)
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
t]On Behalf Of Naintara Jain
Sent: Tuesday, June 04, 2002 2:37 PM
To: Ricardo Fitzgerald; [EMAIL PROTECTED]
Subject: RE: [PHP] Logic -- conditional statements
The problem here is that you have defined three different variables
$value1,$value2,$value3.
Keep only one variable (say,$valueChk) that can take values 1,2 or 3.
Then check for the condition.
And there's another mistake in the script, you are checking
---if ($value2 ==0)---
twice, you probably mean to check for "$value1 ==1" (for the first of the
"$value2 ==0" checks).
Once you are through with these changes, your script will work perfectly.
And if you feel like improving it you need not repeat the <td> statements.
You can merely append the additional rows depending on the value of the
variable you set (say, $valueChk).
the following isn't the actual script, but mainly the logic.
$table="<table>"
if($valueChk==0)
exit
if($valueChk==1)
{
//.....append the first <TR><TD> statement to $table variable
$table .= "<TR><TD> ";
}
if($valueChk==2)
{
//.....append the second <TR><TD> statement to $table variable
}
if($valueChk==3)
{
//.....append the third <TR><TD> statement to $table variable
}
//now close the table tag and echo the $table variable
you'll get the table with the desired number of rows.
-Naintara
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]
t]On Behalf Of Ricardo Fitzgerald
Sent: Friday, July 10, 2893 3:44 PM
To: [EMAIL PROTECTED]
Subject: [PHP] Logic -- conditional statements
Hi to all,
I'm trying to echo a neat table with values from a form, depending on
the values it echoes a table with one row with two or with three:
Then I have conditional nested statements, to validate these variables
and wrote the table with the proper values in each case, the problem
is the table is displayed 3 times instead of 1 each time it finds a
value TRUE!
I need it to display only once, I mean in the first instance the
table, has 1 row, the second 2 rows, the third 3 rows, and they are
independent.
The code is something like:
//Value1 is always 1
if ($value1 == 0)
{
exit
}
if ($value2 ==0)
{
echo // echoes the table
.
.
."<td ... >$variable1 ...
."<td ... >$variable2...
."<td ... >$variable3 ...
."<td ... >$variable4 ...
}
if($value2 == 0)
{
.
.
echo // echoes the table
.
.
."<td ... >$variable1 ...
."<td ... >$variable2...
."<td ... >$variable3 ...
."<td ... >$variable4 ...
."<tr> /next row
.
."<td ... >$variable5 ...
."<td ... >$variable6...
."<td ... >$variable7 ...
."<td ... >$variable8 ...
."</tr>
.
.
}
if($value3 == 3)
{
.
.
echo // echoes the table
.
.
."<td ... >$variable1 ...
."<td ... >$variable2...
."<td ... >$variable3 ...
."<td ... >$variable4 ...
."<tr> /next row
.
."<td ... >$variable5 ...
."<td ... >$variable6...
."<td ... >$variable7 ...
."<td ... >$variable8 ...
."</tr>
.
.
."<td ... >$variable9 ...
."<td ... >$variable10...
."<td ... >$variable11 ...
."<td ... >$variable12 ...
."</tr>
.
.
//and then closes the php script,
TIA
Regards,
Rick
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.363 / Virus Database: 201 - Release Date: 05/21/2002
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php