Mysql/PHP not displaying all rows

HoosautAssomi

New Member
Im creating a simple message board with php/mysql. Users enter their name and a message, javascript displays the message immediately, and php/mysql stores it in a database. When the page loads, it should display all the messages in the database in a formatted list.However, it seems that my php is displaying only some of the messages arbitrarily. They are in the proper chronological order but some are missing and it only displays 4 of them. Manually looking at the entries in the database, I can see that the posted messages are indeed being stored in their table. They're just not ALL being displayed. wierd.Heres the HTML/PHP that displays the messages:\[code\]<?php $records = getMessages(); //see getMessages() function below $names = $records["names"]; $messages = $records["messages"]; $dates = $records["dates"]; for($i = count($records); $i > 0; $i--){ ?> <div class="message"> <p class="message_txt"><?php echo $messages[$i];?></p> <div> <div class="message_name"> <?php echo $names[$i];?> </div> <div class="message_date"> <small> <?php echo "Posted on "; echo date("F j, Y",strtotime($dates[$i])); ?> </small> </div> </div></div><?php } ?>\[/code\]Heres the getMessages() function from above:\[code\]function getMessages(){ $conn = connect("wedding"); $ids; $names; $messages; $dates; $get_messages_query = "SELECT id, name, message, date FROM messages;"; $get_messages_result = mysql_query($get_messages_query,$conn) or die(mysql_error()); $i = 0; while($row = mysql_fetch_array($get_messages_result)){ $ids[$i] = $row["id"]; $names[$i] = $row["name"]; $messages[$i] = $row["message"]; $dates[$i] = $row["date"]; $i++; } $entries = array("ids" => $ids, "names" => $names, "messages" => $messages, "dates" => $dates ); return $entries;}\[/code\]And this is the output:\[code\]<div class="message"> <p class="message_txt">Yo this is a message</p> <div> <div class="message_name">Bob</div> <div class="message_date"><small>Posted on September 18, 2010</small></div> </div> </div> <div class="message"> <p class="message_txt">This is a message another</p> <div> <div class="message_name">Andrew</div> <div class="message_date"><small>Posted on September 6, 2010</small></div> </div> </div> <div class="message"> <p class="message_txt">And another message</p> <div> <div class="message_name">Andrew</div> <div class="message_date"><small>Posted on September 6, 2010</small></div> </div> </div> <div class="message"> <p class="message_txt">This is a message</p> <div> <div class="message_name">Andrew</div> <div class="message_date"><small>Posted on August 27, 2010</small></div> </div> </div> \[/code\]Im not sure whats going on here. It seems simple enough. I suppose it might be some small idiotic error I can't see... but I can't see it.Any assistance would be appreciated.
 
Back
Top