Erm yes, and then try and see if it works?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'; }
unexpected T_IF Issues
Moderator: General Moderators
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>';
}
}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>';
}
}Advice taken on board:
Just another problem the other if statment is not outputting the desired colour, it just ouputs
Just another problem the other if statment is not outputting the desired colour, it just ouputs
Code: Select all
$colourCode: 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>';
}
}- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
You've written it correctly everywhere but there.ghadacr wrote:Code: Select all
echo '<td $colour>' . $row['Notes' ] . '</td>';
initially i saw the mistake, then i changed it to this:
Then i was not getting the output:
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>';
}
}
?>now i'm getting nothing, which is strange..Is it my if or else statement ??????$colour
- superdezign
- DevNet Master
- Posts: 4135
- Joined: Sat Jan 20, 2007 11:06 pm
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..
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>';
}This is what i got now
[/size][/size]
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>';
}