dennismonsewicz Posted September 9, 2009 Share Posted September 9, 2009 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 More sharing options...
SilveR316 Posted September 9, 2009 Share Posted September 9, 2009 What's value inside the span in your output? Link to comment https://forums.phpfreaks.com/topic/173701-solved-extra-span-added-while-loop-runs/#findComment-915631 Share on other sites More sharing options...
dennismonsewicz Posted September 9, 2009 Author Share Posted September 9, 2009 a table name from my database Link to comment https://forums.phpfreaks.com/topic/173701-solved-extra-span-added-while-loop-runs/#findComment-915636 Share on other sites More sharing options...
SilveR316 Posted September 9, 2009 Share Posted September 9, 2009 I meant in the extra span. Are any of the names being duplicated? Link to comment https://forums.phpfreaks.com/topic/173701-solved-extra-span-added-while-loop-runs/#findComment-915637 Share on other sites More sharing options...
dennismonsewicz Posted September 9, 2009 Author Share Posted September 9, 2009 oh gotcha... no its just a blank span for some reason Link to comment https://forums.phpfreaks.com/topic/173701-solved-extra-span-added-while-loop-runs/#findComment-915639 Share on other sites More sharing options...
dennismonsewicz Posted September 9, 2009 Author Share Posted September 9, 2009 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>'; } } Link to comment https://forums.phpfreaks.com/topic/173701-solved-extra-span-added-while-loop-runs/#findComment-915641 Share on other sites More sharing options...
SilveR316 Posted September 9, 2009 Share Posted September 9, 2009 I see it now. You could also have started your $i at 1 instead of 0. Link to comment https://forums.phpfreaks.com/topic/173701-solved-extra-span-added-while-loop-runs/#findComment-915651 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.