Some wierd issue with my arrays

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
kanshou
Forum Commoner
Posts: 47
Joined: Sun Aug 03, 2003 1:57 pm
Location: San Diego
Contact:

Some wierd issue with my arrays

Post by kanshou »

I am having a problem with an array displaying info. It generates links based on an id#, then displays the id# as well. The problem is, it stops making it a link after the 9th array row. Here's the code.

Code: Select all

<?php
foreach ($row as $heading=>$column) {

			 echo "<TD><b>";

             if (in_array ($heading, $allowed_order)) {

	                     echo "<a href="{$_SERVER['PHP_SELF']}?order=$heading">$heading</a>";

	                         }
	                         else
	                         {

		                          echo $heading;

		                          }

		                          echo "</b></TD>\n";

		                          }

		                          echo "</TR>\n";


		                          /* reset the $result set back to the first row and

		                          * display the data */

		                          mysql_data_seek ($result, 0);

		                          $i = 0; // sets up the counter for alternating table row colors.

		                          while ($row = mysql_fetch_assoc ($result)) {

			                            echo "<TR>\n";

			                              foreach ($row as $column) {
//My alternating colors
			                              			if($i % 2 == 0) //checks to see if the line is an even number
																{

																echo "<td font face="Arial" valign="center" bgcolor="#EEF7ff">";

																}else{

																// The whole purpose of this second area is to just change the highlighting of the table

																echo "<td font face="Arial" valign="center" bgcolor="#DBEDff">";

															}
//End Alternating colors
													if ($column == $column["id"]){

														echo ("<a href="editentry.php?id=$column">$column</a></TD>");

													}else{

														echo "$column</TD>\n";  // Original display
													}

				                                   }

				                                    echo "</TR>\n";

				                                    $i++;

				                                    }

				                                    echo "</TABLE>\n";

				                              echo "</table>";

?>
Here's what the output to HTML looks like

Code: Select all

<TR>
<td font face="Arial" valign="center" bgcolor="#EEF7ff"><a href="editentry.php?id=4">4</a></TD><td font face="Arial" valign="center" bgcolor="#EEF7ff">some title</TD>
<td font face="Arial" valign="center" bgcolor="#EEF7ff">Tree Glitch: Jump out of world.</TD>
<td font face="Arial" valign="center" bgcolor="#EEF7ff">locationTD>
<td font face="Arial" valign="center" bgcolor="#EEF7ff">00:00:00</TD>
<td font face="Arial" valign="center" bgcolor="#EEF7ff">so on and so forthTD>
<td font face="Arial" valign="center" bgcolor="#EEF7ff"><a href="editentry.php?id="></a></TD></TR>
Thanks!!
Rand
Post Reply