Jump to content

Printing An Array


justinbriggs1

Recommended Posts

Hello, would someone mind taking a look at some simple code for me, can't seem to put my finger on why this is not working. I am only trying to print the contents of a multidimensional array. I left out all of the db connection stuff. I keep getting a invalid argument supplied for the first for statement.

$query = "SELECT * FROM blog JOIN admin ON admin.admin_id=blog.admin_id WHERE admin.admin_id='$_SESSION[admin_id]'";	$result = mysql_query($query, $connection);	//$num_rows = mysql_num_rows($result);	  $admin_row = mysql_fetch_assoc($result);		while($admin_row = mysql_fetch_assoc($result))	{	 echo "<li><a>" . $admin_row['blog_title'] . "</a> <a href='admin_blogedit.php?blog_id=" . $admin_row['blog_id'] . "'>Edit</a></li>";	}  	echo "<ol>";		for ($row = 0; $row < 3; $row++)	{		echo "<li><b>The row number" . $row . "</b>";		echo "<ul>";				foreach($admin_row[$row] as $key => $value)		{						echo "<li>".$value."</li>";		}			echo "</ul>";		echo "</li>";	}echo "</ol>";

Any help would be appreciated.

Link to comment
Share on other sites

hi use this code.<?phperror_reporting(E_ALL);ini_set('html_errors', 1);ini_set('log_errors', 0);ini_set('display_errors', 1);include ("dbcon.php");$sql=mysql_query("Select * From admin");$i = 0;$j = 3;echo "<table>";while($query = mysql_fetch_array($sql)){ if(($i%3) == 0) { echo "<tr>"; } $rename = $query['subcategory']; ?><td><?php echo $rename; ?></td><?phpif (($i % $j) == ($j - 1)) { echo "</tr>"; } $i++;}echo "</table>";?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...