troubleshooting Question

Pass a single value out of a loop

Avatar of ggjones
ggjonesFlag for Afghanistan asked on
PHP
6 Comments1 Solution263 ViewsLast Modified:
I need to pass a single value from a loop.

Currently, what happens is that the value that I need gets over-written during the next loop.

If I use "break", the rest of the processing and the next loops get skipped, which needs not to happen..

How can this be done?

regards,

GJ

.



ID|TYPE|URL|LABEL
1|4|www.google.com|google
2|2|www.yahoo.com|yahoo
3|1|www.bing.com|bing
4|2|www.bookface.com|bookface

while(row = mysql_fetch_assoc($result)){


	if (row[TYPE] == 1){

		$myURL = row[URL];

	}

$theLinks .= "\n<div><a href='http://" . row[URL] . "' target='_blank'>" . row[LABEL] . "</a></div>"; 

}

echo $myURL;
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros