If statement

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

If statement

Post by mhouldridge »

Hi,

I cannot get the following if statement to work.

Code: Select all

if ($list = "IP") {
	$query = mysql_query ("SELECT * FROM ip WHERE $list LIKE '%$search%'");
	echo "<TABLE BORDER=\"0\" table width=\"100%\" cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"#cccccc\" class=\"standard\">\n";
	echo "<TR bgcolor=\"#efefef\"><TD font colour=\"red\" width=\"15%\"><b>Asset</b></TD></TR>\n";
	while($rows=mysql_fetch_array($query)) ;
	echo "<TR bgcolor=\"efefef\" onmouseover=this.className=\"test2\" onmouseout=this.className=\"test\" class=\"test\"><td><a href='viewasset.php?varl=".$rows["asset"]."' class=\"blue5\>".$rows["asset"]."</a></TD>\n";
	echo "</TR>\n";
	}
	echo "</TABLE>\n";
	}	
else {  
	$result = mysql_query("SELECT * FROM dedicated WHERE $list LIKE '%$search%'");
	echo "<TABLE BORDER=\"0\" table width=\"100%\" cellspacing=\"1\" cellpadding=\"5\" bgcolor=\"#cccccc\" class=\"standard\">\n";
	echo "<TR bgcolor=\"#efefef\"><TD font colour=\"red\" width=\"15%\"><b>Asset</b></TD><TD width=\"30%\"><t><b>Title</b></TD><TD width=\"25%\"><b>IP Address</b></TD><TD width=\"15%\"><b>Reconciled</b></TD><TD width=\"5%\"></TD><TD width=\"5%\"></TD></TR>\n";
	while($r=mysql_fetch_array($result)) {           
 	echo "<TR bgcolor=\"efefef\" onmouseover=this.className=\"test2\" onmouseout=this.className=\"test\" class=\"test\"><td><a href='viewasset.php?varl=".$r["asset"]."' class=\"blue5\">".$r["asset"]."</a></td><td>".$r["title"]."</td><td>".$r["customer"]."</td><td>".$r["IP"]."</td><TD><a href='sysdocupdate3.php?varl=".$r['asset']."'><img src=\"edit.gif\" alt=\"Delete\" border=\"0\" /></a></TD><TD><a href='deleteget.php?varl=".$r['asset']."'><img src=\"b_drop.gif\" alt=\"Delete\" border=\"0\" /></a></TD>\n";   
	echo "</TR>\n";
	}
	echo "</TABLE>\n";
	}
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I'd let you sweat but....

Code: Select all

if ($list = "IP") {
Such a common mistake ;)

Code: Select all

if ($list == "IP") {
User avatar
mhouldridge
Forum Contributor
Posts: 267
Joined: Wed Jan 26, 2005 5:13 am

Post by mhouldridge »

DUH!

Just call me stupid.

thanks for this.
Post Reply