Page 2 of 3

Posted: Wed Jul 04, 2007 6:23 am
by idevlin
ghadacr wrote:

Code: Select all

if  ($row['Confirmed' ] > 0)  { 
			echo "Hello"; 
			} else { 
			   echo '<input type="checkbox" name="HotelRoomID[]" value="' . $row['HotelRoomID'] . '" />Select  ' . $row['RoomType'] .' to update';	   
			   }
Erm yes, and then try and see if it works?

Posted: Wed Jul 04, 2007 6:24 am
by ghadacr
Hey, nothing works....Hmmm i got a slight feeling something else is stopping this from working....

Posted: Wed Jul 04, 2007 9:09 am
by ghadacr
The new problem know is that the code is not outputting the desired hyperlink if the if statement is conditioned to true, instead it just ouputs a blank...

Code: Select all

while ($row = mssql_fetch_array($result))
		
{ 
    echo '<tr>';
	echo '<td><a href="roomdetails.php?HotelRoomID=' . $row['HotelRoomID'] . '">More information on hotel room</a></td>'; 
    echo '<td>' . $row['HotelName' ] . '</td>'; 
	echo '<td>' . $row['RoomType' ] . '</td>'; 
	echo '<td>' . $row['AvailableFrom' ] . '</td>';
	echo '<td>' . $row['AvailableTo' ] . '</td>';
	echo '<td><input type="hidden" name="datefrom" value="' . $datefrom . '" />' . $datefrom .'</td>';
	echo '<td><input type="hidden" name="dateto" value="' . $dateto . '" />' . $dateto .'</td>';
	echo '<td>' . $row['Notes' ] . '</td>';
   
	if  ($row['Confirmed' ] == 1)  { 
			'<td bgcolor="#FFFF00"><a href="roomdetails.php?HotelRoomID=' . $row['HotelRoomID'] . '">More information on hotel room</a></td>';  } else { 
			   echo '<td><input type="checkbox" name="HotelRoomID[]" value="' . $row['HotelRoomID'] . '" />Select  ' . $row['RoomType'] .' to update</td>';	   
			   
	
    echo '</tr>'; 



}


 }

Posted: Wed Jul 04, 2007 9:21 am
by feyd
There's no echo associated with the statement(s) in the true side of the if.

Posted: Wed Jul 04, 2007 9:32 am
by ghadacr
Thanks, that got it working, its always good to have another pair of eyes.... :D

Posted: Wed Jul 04, 2007 9:33 am
by volka
Would be easier to see the problem if the code was properly indented

Code: Select all

<?php
while ( $row=mssql_fetch_array($result) ) {
  echo '<tr>';
  echo '<td><a href="roomdetails.php?HotelRoomID=' . $row['HotelRoomID'] . '">More information on hotel room</a></td>';
  echo '<td>' . $row['HotelName' ] . '</td>';
  echo '<td>' . $row['RoomType' ] . '</td>';
  echo '<td>' . $row['AvailableFrom' ] . '</td>';
  echo '<td>' . $row['AvailableTo' ] . '</td>';
  echo '<td><input type="hidden" name="datefrom" value="' . $datefrom . '" />' . $datefrom .'</td>';
  echo '<td><input type="hidden" name="dateto" value="' . $dateto . '" />' . $dateto .'</td>';
  echo '<td>' . $row['Notes' ] . '</td>';

  if  ($row['Confirmed' ] == 1)  {
    '<td bgcolor="#FFFF00"><a href="roomdetails.php?HotelRoomID=' . $row['HotelRoomID'] . '">More information on hotel room</a></td>';
  }
  else {
    echo '<td><input type="checkbox" name="HotelRoomID[]" value="' . $row['HotelRoomID'] . '" />
      Select  ' . $row['RoomType'] .' to update</td>';    
    echo '</tr>';
  }
}

Posted: Wed Jul 04, 2007 10:22 am
by ghadacr
Advice taken on board:

Just another problem the other if statment is not outputting the desired colour, it just ouputs

Code: Select all

$colour

Code: Select all

while ($row = mssql_fetch_array($result))
		
{ 
$colour="";
if($row['Confirmed' ] == 1)  { 
echo $colour == "bgcolor=#FFFF00";

}else{
echo $colour == "bgcolor=";

    echo '<tr>';
	echo '<td' . $colour .'><a href="roomdetails.php?HotelRoomID=' . $row['HotelRoomID'] . '">More information on hotel room</a></td>'; 
    echo '<td' . $colour .'>' . $row['HotelName' ] . '</td>'; 
	echo '<td'.  $colour .'>' . $row['RoomType' ] . '</td>'; 
	echo '<td' . $colour . '>' . $row['AvailableFrom' ] . '</td>';
	echo '<td' . $colour . '>' . $row['AvailableTo' ] . '</td>';
	echo '<td' . $colour .'><input type="hidden" name="datefrom" value="' . $datefrom . '" />' . $datefrom .'</td>';
	echo '<td' . $colour .'><input type="hidden" name="dateto" value="' . $dateto . '" />' . $dateto .'</td>';
	echo '<td $colour>' . $row['Notes' ] . '</td>';
   
	if  ($row['Confirmed' ] == 1)  { 
			echo '<td' . $colour .'><a href="roomdetails.php?HotelRoomID=' . $row['HotelRoomID'] . '">More information on hotel room</a></td>';  } else { 
			   echo '<td' . $colour .'><input type="checkbox" name="HotelRoomID[]" value="' . $row['HotelRoomID'] . '" />Select  ' . $row['RoomType'] .' to update</td>';	   
			   } 
	
    echo '</tr>'; 
}


}

Posted: Wed Jul 04, 2007 10:44 am
by superdezign
ghadacr wrote:

Code: Select all

echo '<td $colour>' . $row['Notes' ] . '</td>';
You've written it correctly everywhere but there.

Posted: Wed Jul 04, 2007 10:58 am
by ghadacr
initially i saw the mistake, then i changed it to this:

Code: Select all

<?php 

	
while ($row = mssql_fetch_array($result))
		
{ 
$colour="";
if($row['Confirmed' ] == 1)  { 
echo $colour == "bgcolor=#FFFF00";

}else{
echo $colour == "bgcolor=#990033";

    echo '<tr>';
	echo '<td' . $colour .'><a href="roomdetails.php?HotelRoomID=' . $row['HotelRoomID'] . '">More information on hotel room</a></td>'; 
    echo '<td' . $colour .'>' . $row['HotelName' ] . '</td>'; 
	echo '<td'.  $colour .'>' . $row['RoomType' ] . '</td>'; 
	echo '<td' . $colour . '>' . $row['AvailableFrom' ] . '</td>';
	echo '<td' . $colour . '>' . $row['AvailableTo' ] . '</td>';
	echo '<td' . $colour .'><input type="hidden" name="datefrom" value="' . $datefrom . '" />' . $datefrom .'</td>';
	echo '<td' . $colour .'><input type="hidden" name="dateto" value="' . $dateto . '" />' . $dateto .'</td>';
	echo '<td' . $colour .'>' . $row['Notes' ] . '</td>';
   
	if  ($row['Confirmed' ] == 1)  { 
			echo '<td><a href="roomdetails.php?HotelRoomID=' . $row['HotelRoomID'] . '">More information on hotel room</a></td>';  } else { 
			   echo '<td><input type="checkbox" name="HotelRoomID[]" value="' . $row['HotelRoomID'] . '" />Select  ' . $row['RoomType'] .' to update</td>';	   
			   } 
	
    echo '</tr>'; 
}


}



?>
Then i was not getting the output:
$colour
now i'm getting nothing, which is strange..Is it my if or else statement ??????

Posted: Wed Jul 04, 2007 11:08 am
by superdezign
Probably. If you're if statement is true, absolutely nothing happens. It looks like it'd echo '0.'

Posted: Thu Jul 05, 2007 3:34 am
by ghadacr
Ok i have revised the code. Now i'm just getting black... i think i'm not constructing the code properly!!!!

I want the colour to print out what ever the if else statement executes, so it could be either $colour1 or $colour2.... Help please..

Code: Select all

while ($row = mssql_fetch_array($result))
		
{ 
$colour1="white";
$colour2="blue";
$colour = $colour2 || $colour1;
if($row['Confirmed' ] == 1)  { 
	echo $colour1 == $colour;
	}

else{
	echo $colour2 == $colour;
}
    echo '<tr bgcolor='.  $colour .'>';
	
    echo '<td>' . $row['HotelName' ] . '</td>'; 
	echo '<td>' . $row['RoomType' ] . '</td>'; 
	echo '<td bgcolor='.  $colour .'>' . $row['AvailableFrom' ] . '</td>';
	echo '<td>' . $row['AvailableTo' ] . '</td>';
	echo '<td><input type="hidden" name="datefrom" value="' . $datefrom . '" />' . $datefrom .'</td>';
	echo '<td><input type="hidden" name="dateto" value="' . $dateto . '" />' . $dateto .'</td>';
	echo '<td>' . $row['Notes' ] . '</td>';
   
	if  ($row['Confirmed' ] == 1)  { 
			echo '<td><a href="roomdetails.php?HotelRoomID=' . $row['HotelRoomID'] . '">This room has been confirmed, select for more information</a></td>';  } 
	else { 
		echo '<td><input type="checkbox" name="HotelRoomID[]" value="' . $row['HotelRoomID'] . '" />Select  ' . $row['RoomType'] .' to update</td>';	   
		} 

    echo '</tr>'; 
}

Posted: Thu Jul 05, 2007 4:04 am
by volka
== tests for equality
= assigns a value
echo prints something

what does
echo $colour1 == $colour;
do?
Please indent and format your code properly.

Posted: Thu Jul 05, 2007 4:15 am
by ghadacr
This is what i got now

Code: Select all

while ($row = mssql_fetch_array($result))
		
 { 
  	$colour;
  	$colour1="red";
  	$colour2="blue";

if($row['Confirmed' ] == 1)  { 
	echo $colour1($colour);
	}

else{
	echo $colour2($colour);
}
    	echo '<tr bgcolor='.  $colour .'>';
	
    	echo '<td>' . $row['HotelName' ] . '</td>'; 
	echo '<td>' . $row['RoomType' ] . '</td>'; 
	echo '<td>' . $row['AvailableFrom' ] . '</td>';
	echo '<td>' . $row['AvailableTo' ] . '</td>';
	echo '<td><input type="hidden" name="dateto" value="' . $dateto . '" />' . $dateto .'</td>';
	echo '<td>' . $row['Notes' ] . '</td>';
   
if  ($row['Confirmed' ] == 1)  { 
			echo '<td><a href="roomdetails.php?HotelRoomID=' . $row['HotelRoomID'] . '">This room has been confirmed, select for more information</a></td>';  } 
	else { 
		echo '<td><input type="checkbox" name="HotelRoomID[]" value="' . $row['HotelRoomID'] . '" />Select  ' . $row['RoomType'] .' to update</td>';	   
		} 

    echo '</tr>'; 
}
[/size][/size]

Posted: Thu Jul 05, 2007 4:23 am
by volka
parentheses?
I thought you wanted to assign a value to the variable $colour?

Please indent and format your code properly.


p.s.: You really should take some basic tutorials.

Posted: Thu Jul 05, 2007 4:28 am
by ghadacr
[quote="volka"
p.s.: You really should take some basic tutorials.[/quote]

I dont think that is helpful....

I want color to either execute color1 or color2.......