Jump to content

If statement help


Jouatt

Recommended Posts

I have a table on a page that displays info from a database and everything is working fine but I want it so if the user entered data from another page to a certain field then the row on my data display table will turn red. Right now I have a If statement in every row of my table. Is it possible to have two if statements in a row? Here is my page code with the table.

<?
include "include/session.php";

include "include/z_db.php";
?>
<?

require "bottom.php";
?>
<!doctype html public "-//w3c//dtd html 3.2//en">

<html>

</head>

<!-- <body bgcolor="#339999"> -->
<body bgcolor="white">

<img src="logo.jpg" width="197" height="193" align="right"><br /><br /><br /><br /><br />
<br /><br /><br /><br /><br />
<FORM>
<INPUT TYPE="BUTTON" VALUE="New Tour" ONCLICK="window.location.href='http://www.integranite.net/EAToursDemo/Input.php'">
</FORM>
<?php
$result = mysql_query("SELECT * FROM Project");
?>
<div style="overflow:auto; height:30px; width:1650px">
<?php
echo "<table border='1'>
<tr>
<th width='200'>School</th>
<th width='200'>Teacher</th>
<th>First Contact start date</th>
<th>Development Start</th>
<th>Development End</th>
<th>Pricing Start</th>
<th>Pricing End</th>
<th>Marketing Start date</th>
<th>Price Based On</th>
<th>Trip Assigned To</th>
<th>Trip Made</th>
<th width='104'>Notes</th>
</tr>";
echo "</table>";
echo "</div>";
?>
<div style="overflow:auto; height:400px; width:1650px">
<?php
while($row = mysql_fetch_array($result))
{ 
$checkbox = '';
if ($row['TripMade'] == 1) $checkbox = ' checked'; 
?>
<!--<div style="overflow:auto; height:40px; width:155px">--!>
<table cellpadding="0" cellspacing="0" style="width:50px;">
<?php
echo "<table border='1'>";
echo "<tr>"; 
echo "<td width='200'>" .$row['School'] . "</td>";
echo "<td width='200'>" .$row['Teacher'] . "</td>";
if(!strcmp($row['dtFirstContactSt']&& $row['dtMarketingSt'] , '0000-00-00' && '0000-00-00')) {
echo "<td width='156'>" . "&nbsp </td>";
} else {
echo "<td bgcolor=FF0000 width='156'>" .$row['dtFirstContactSt']. "</td>";
}
if(!strcmp($row['dtDevelopmentSt'], '0000-00-00')) {
echo "<td width='126'>" . "&nbsp </td>";
} else {
echo "<td width='126'>" .$row['dtDevelopmentSt']. "</td>";
}
if(!strcmp($row['dtDevelopmentEnd'], '0000-00-00')) {
echo "<td width='119'>" . "&nbsp </td>";
} else {
echo "<td width='119'>" .$row['dtDevelopmentEnd']. "</td>";
};
if(!strcmp($row['dtPricingSt'], '0000-00-00')) {
echo "<td width='83'>" . "&nbsp </td>";
} else {
echo "<td width='83'>" .$row['dtPricingSt']. "</td>";
}
if(!strcmp($row['dtPricingEnd'], '0000-00-00')) {
echo "<td width='76'>" . "&nbsp </td>";
} else {
echo "<td width='76'>" .$row['dtPricingEnd']. "</td>";
}
if(!strcmp($row['dtMarketingSt'], '0000-00-00')) {
echo "<td width='142'>" . "&nbsp </td>";
} else {
echo "<td width='142'>" .$row['dtMarketingSt']. "</td>";
}
echo "<td width='104'>" .$row['PriceBasedOn']. "</td>";
echo "<td width='115'>" .$row['TripAssignedTo']. "</td>"; 
?>
<td width="72"><input type="checkbox" name="TripMade" value="Yes" <?= $checkbox ?>></td>
<td><textarea name="Notes" rows="1" cols="10"><?php echo $row["Notes"]?></textarea> </td>
<?php
echo "<td>" . "<a href=Edit_Form.php?UniqueIdentifier=$row[uniqueIdentifier]> Edit </a></td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
mysql_close($con);
?>

<br />

<meta name="GENERATOR" content="Arachnophilia 4.0">
<meta name="FORMATTER" content="Arachnophilia 4.0">
</head>

<body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<center>


</body>

</html>

The first IF statement is what i am trying to do but just dont know how to code it.

I know its kind hard to understand but any help is appreciated.

Link to comment
https://forums.phpfreaks.com/topic/208694-if-statement-help/
Share on other sites

Dude,

 

I couldn't understand your exact requirement. But still i can give you some tips to follow.

 

You have used strcmp function (http://php.net/manual/en/function.strcmp.php ) .It expects 2 arguments. But the way you used is something different.

 

Also you are creating table inside the while loop. So for every row of database record, 1 new table will get created. You may need to do something like this

 

echo '<table>';

while($row = mysql_fetch_array($query)){

echo '<tr>';

if(strcmp($str1, $str2))

    echo '<td>'.$value.'</td>';

else

    echo '<td>'.$value1.'</td>';

-

-

-

-

-

-

-

echo '</tr>';

}

echo '</table>';

 

----- Hope this will help you

 

 

Link to comment
https://forums.phpfreaks.com/topic/208694-if-statement-help/#findComment-1092006
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.