justinbriggs1 Posted February 22, 2009 Share Posted February 22, 2009 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 More sharing options...
jlhaslip Posted February 22, 2009 Share Posted February 22, 2009 What part is not working?Echo some plain text before each loop to see where the problem is. Link to comment Share on other sites More sharing options...
justinbriggs1 Posted February 22, 2009 Author Share Posted February 22, 2009 What part is not working?Echo some plain text before each loop to see where the problem is.Hey thanks, I think I got it. I was confused on what the mysql_fetch_assoc was doing, but I have it now. Link to comment Share on other sites More sharing options...
jsilvia Posted February 23, 2009 Share Posted February 23, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.