Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Quickie about a foreach statement?

$
0
0

Currently i've got this code:

	while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			if (!empty($row['OneDel1'])){ $OneDel1 == 1; }
		}

How would I go about replacing the if statement with a foreach statement that cycles through a number of columns from the database? Basically a shorter way of:

	while($row = mysql_fetch_array($result, MYSQL_ASSOC))
		{
			if (!empty($row['OneDel1'])){ $OneDel1 == 1; }
			if (!empty($row['OneDel2'])){ $OneDel2 == 1; }
			if (!empty($row['OneDel3'])){ $OneDel3 == 1; }
			if (!empty($row['OneDel4'])){ $OneDel4 == 1; }
		}

And so on?

 

Thanks in advanced!


Viewing all articles
Browse latest Browse all 13200

Latest Images

Trending Articles



Latest Images