Jump to content

[SOLVED] extra span added while loop runs


dennismonsewicz

Recommended Posts

I have the following loop:

 

mysql_connect('localhost', '*****', ''*****');
	mysql_select_db(''*****');

	$q = mysql_query("SHOW TABLES FROM tblName");

	while($row = mysql_fetch_array($q)) {
		$col = $row;
		$count = count($col);
		for($i = 0; $i < $count; $i++) {
			echo '<span>' . $col[$i] . '</span>';
		}
	}

 

When you run the code it adds an extra span tag in there... I can't figure out why!

Link to comment
https://forums.phpfreaks.com/topic/173701-solved-extra-span-added-while-loop-runs/
Share on other sites

figured it out :)

 

fixed code:

 

mysql_connect('localhost', '*******', '*******');
	mysql_select_db('*******');

	$q = mysql_query("SHOW TABLES FROM *******");

	while($row = mysql_fetch_array($q)) {
		$col = $row;
		$count = count($col) - 1;
		for($i = 0; $i < $count; $i++) {
			echo '<span>' . $col[$i] . '</span>';
		}
	}

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.