runnerjp Posted March 3, 2010 Share Posted March 3, 2010 Hey i have my forum set up and i want to have a number next to the post.. e.g #2 #3# ect Below is my array and the page displayed for each array $getreplies = "Select * from forumtutorial_posts where parentid='$forumpostid' ORDER BY showtime $max"; //getting replies $getreplies2=mysql_query($getreplies) or die(mysql_error() . "Could not get replies"); while ($getreplies3=mysql_fetch_array($getreplies2)) { ?><br /> <table width = "90%" align="center" cellpadding = "0" cellspacing = "0" > <tr> <td> <table width = "100%" align = "center" cellpadding = "0" cellspacing = "0" class="loggedin"> <tr> <td colspan="3" align="right" class = 'border'> <table width="100%"> <tr> <td width="15%" align="left"><font size="2" color="white"> <?php foreach(array_keys($getreplies2) as $key){ echo $key ." ". $getreplies2[$key]."<br>"; } ?> <a name="<?php echo $getreplies3['postid'] ?>"> </a><a href ='http://www.runningprofiles.com/members/index.php?page=message&forum=<?php echo $forum ?>&id=<?php echo $forumpostid ?>#<?php echo $getreplies3['postid'] ?>'><strong>RE: <? echo $gettopic3[title] ?></strong></a></span></font></td> <td width="32%" align="left"> </td> <td width="33%" align="right"><font size="2" color="white">» Replied obv more below but you only need to see code above really. Where it says : <?php foreach(array_keys($getreplies2) as $key){ echo $key ." ". $getreplies2[$key]."<br>"; } ?> i wanted it to display the array number but also i need it to start from #2. Is any 1 able to help? Quote Link to comment Share on other sites More sharing options...
aeroswat Posted March 3, 2010 Share Posted March 3, 2010 Is it displaying the array number now? If it is then all you have to do is slip in if statement in there ofc to test if the $key is < 2 Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 3, 2010 Author Share Posted March 3, 2010 No i just get: Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/runningp/public_html/members/include/message.php on line 271 Warning: Invalid argument supplied for foreach() in /home/runningp/public_html/members/include/message.php on line 271 Quote Link to comment Share on other sites More sharing options...
aeroswat Posted March 3, 2010 Share Posted March 3, 2010 No i just get: Warning: array_keys() [function.array-keys]: The first argument should be an array in /home/runningp/public_html/members/include/message.php on line 271 Warning: Invalid argument supplied for foreach() in /home/runningp/public_html/members/include/message.php on line 271 Silly goose you need to put it into an array. A result set is not a traditional array. Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 3, 2010 Author Share Posted March 3, 2010 Would i just add arry() around it? Quote Link to comment Share on other sites More sharing options...
aeroswat Posted March 3, 2010 Share Posted March 3, 2010 Would i just add arry() around it? No you would do something like this $arr = array(); while($row = mysql_fetch_assoc($resultset)){ $arr[] = $row; } Then all ur stuff will be in the $arr array Quote Link to comment Share on other sites More sharing options...
runnerjp Posted March 4, 2010 Author Share Posted March 4, 2010 ok i have tried this... $counter2 = 0; $counter2++; $getreplies = "Select * from forumtutorial_posts where parentid='$forumpostid' ORDER BY showtime $max"; //getting replies $getreplies2=mysql_query($getreplies) or die(mysql_error() . "Could not get replies"); while ($getreplies3=mysql_fetch_array($getreplies2)) { ?><br /> <table width = "90%" align="center" cellpadding = "0" cellspacing = "0" > <tr> <td> <table width = "100%" align = "center" cellpadding = "0" cellspacing = "0" class="loggedin"> <tr> <td colspan="3" align="right" class = 'border'> <table width="100%"> <tr> <td width="15%" align="left"><font size="2" color="white"> <?php echo $counter2; ?> put it just has 1 on them all Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.