Page 1 of 1

foreach command

Posted: Wed Jan 21, 2004 8:01 am
by wizzy
Hi People.

Im sorry if this seems simple, but I am still learning php/mysql and I am a bit bemused by this following issue.

There is an existing bit of code that I am trying to alter a little to provide me with a href tag later on in a page. Here is how the code currently is:-

Code: Select all

$data = array_splice($row, 1);
$row_bgcolor = $row_bgcolor1;
foreach ($data as $value) {
	if ($row_bgcolor == $row_bgcolor1) {
		$row_bgcolor = $row_bgcolor2;
	} else {
		$row_bgcolor = $row_bgcolor1;
	}
	$value = explode("|", $value);
	$server_name = array_slice($value, 0, 2);
	$server_status = array_slice($value, 2, -1);
	$server_uptime = array_splice($value, -1, 1);
So, what I have done is created a 4th column in the database for the part of the url which is a variable (its a user ID). How would I go about adding that to the above mentioned code so I can call it later? I havent used the foreach command before, so thats why I am a little confused on it.

thanks in advance.