Need a static (non-repeating) row in a while loop

I’m displaying a somewhat complex table inside a WHILE LOOP with the following code…


switch ($DesigGroup)
{
case 'Animals':
case 'Plants':

// This displays plants and animals...
echo <<<EOD
   <tr class="$DesigGroup $Alternate" style="background-color:$c">
     <td class="$class"><a href="/World/$URL">$Check$DesigD</a>$ast</td>
     <td class="left">$Symbol</td>
     <td class="latin">$Latin</td>
     <td class="left">$Year</td>
   </tr>
EOD;
break;

// EARTH...
case 'earth':
// INTERNAL SWITCH
switch ($DesigGen)
{
 case 'fossil':
// This displays fossils...
echo <<<EOD
   <tr class="{$row["DesigGroup"]} $Alternate" style="background-color:$c">
     <td class="$class"><a href="/World/$URL">$Check$DesigD</a>$ast</td>
     <td class="left">$Symbol</td>
     <td class="latin">$Latin</td>
     <td class="left">$Year</td>
   </tr>
EOD;
break;

Now I want to insert a couple non-repeating rows that aren’t associated with the database table in any way. If I simply insert them, as in the example below, they display but they repeat. Is there some way I can tell a row inside a while loop to display just once?

Other than that, the first row begins in the right location, so that should fix it. The second row is more complicated, but I can probably make it display in the right location if I can just get it to display just once.

Thanks!


switch ($DesigGroup)
{
case 'Animals':
case 'Plants':

// NON-REPEATING ROW #1
echo '<tr><td colspan="4" style="background: #060; color: #fff; text-align: center;"><strong>EcoSymbols</strong></td></tr>';
// This displays plants and animals...
echo <<<EOD
   <tr class="$DesigGroup $Alternate" style="background-color:$c">
     <td class="$class"><a href="/World/$URL">$Check$DesigD</a>$ast</td>
     <td class="left">$Symbol</td>
     <td class="latin">$Latin</td>
     <td class="left">$Year</td>
   </tr>
EOD;
// NON-REPEATING ROW #2
echo '<tr><td colspan="4" style="background: #009; color: #fff; text-align: center;"><strong>Cultural Symbols</strong></td></tr>';
break;

// EARTH...
case 'earth':
// INTERNAL SWITCH
switch ($DesigGen)
{
 case 'fossil':
// This displays fossils...
echo <<<EOD
   <tr class="{$row["DesigGroup"]} $Alternate" style="background-color:$c">
     <td class="$class"><a href="/World/$URL">$Check$DesigD</a>$ast</td>
     <td class="left">$Symbol</td>
     <td class="latin">$Latin</td>
     <td class="left">$Year</td>
   </tr>
EOD;
break;

Can you show us the final result you want to have?

How about you post an array with say 2 or 3 sets, and then show how the resulting table should look. Leave out all the html class and style gubbins, just stick to the data and the basic table you want – and lets focus on the basic logic and the loop.

Create your simplified array and then post the output of:


echo var_export($array, 1);

Sure. I hope it’s OK to post the code for the entire table. I deleted most of the styling to make it easier to read.

There is at least one other thing I need to fix. It should display a row for each of a state’s nicknames (three, in this case). However, I need to play around with my database and query first. If I can’t figure out how to make it work, maybe I’ll have to learn a new trick. :wink:

Thanks.


<thead>
  <tr>
    <th>Designation</th>
    <th>Symbol</th>
    <th><em>Scientific Name</em></th>
    <th>Year</th>
  </tr>
</thead>
<tbody>
  <tr>
    <td colspan="4" style="background: #009; color: #ff0; text-align: center;"><strong>Symbols of State</strong></td>
  </tr>
  
// EVERYTHING BELOW HERE IS INSIDE A WHILE LOOP
  
  <tr>
    <td><a href="/World/Arizona/Flag">Flag</a></td>
    <td></td>
    <td>1917</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Seal">Seal</a></td>
    <td></td>
    <td>1911</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Nickname">Nickname</a></td>
    <td>The Grand Canyon State</td>
    <td></td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Motto">Motto</a></td>
    <td>Ditat Deus&nbsp;&nbsp;<span style="font-size: 85%; background: #009;">[<a href="/World/Arizona/Motto">(Latin...)</a>]</span></td>
    <td>1864</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Song">Anthem</a></td>
    <td>Arizona March Song</td>
    <td>1919</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Song2">Alternate Anthem</a></td>
    <td>Arizona</td>
    <td>1981</td>
  </tr>

* * * * *
// I WANT TO INSERT THE FOLLOWING STATIC ROW
<tr><td colspan="4" style="background: #060; color: #fff; text-align: center;"><strong>EcoSymbols</strong></td></tr>
* * * * *

  <tr>
    <td><a href="/World/Arizona/Flower"><img src="http://Geobop/images/Site/aids/check15.gif" width="15" height="15" alt="check mark (article available)" style="margin-left: -9px; margin-right: 2px;">Flower</a></td>
    <td>saguaro cactus blossom</td>
    <td class="latin">Carnegia gigantea</td>
    <td>1931</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Tree"><img src="http://Geobop/images/Site/aids/check15.gif" width="15" height="15" alt="check mark (article available)" style="margin-left: -9px; margin-right: 2px;">Tree</a></td>
    <td>palo verde</td>
    <td class="latin">Cercidium</td>
    <td>1954</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Bird"><img src="http://Geobop/images/Site/aids/check15.gif" width="15" height="15" alt="check mark (article available)" style="margin-left: -9px; margin-right: 2px;">Bird</a></td>
    <td>cactus wren</td>
    <td class="latin">Campylorhynchus brunneicapillus</td>
    <td>1931</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Mammal">Mammal</a></td>
    <td>ringtail</td>
    <td class="latin">Bassariscus astutus</td>
    <td>1986</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Reptile">Reptile</a></td>
    <td>ridge-nosed rattlesnake</td>
    <td class="latin">Coluber constrictor</td>
    <td>1986</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Amphibian">Amphibian</a></td>
    <td>Arizona tree frog</td>
    <td class="latin">Hyla eximia</td>
    <td>1986</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Fish">Fish</a></td>
    <td>Arizona trout</td>
    <td class="latin">Oncorhynchus apache</td>
    <td>1986</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Insect">Butterfly</a></td>
    <td>two-tailed swallowtail</td>
    <td class="latin">Papilio multicaudata</td>
    <td>2001</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Soil">Soil</a></td>
    <td>Casa Grande</td>
    <td></td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Fossil">Fossil</a></td>
    <td>Arizona petrified wood</td>
    <td>1988</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Mineral">Mineral</a></td>
    <td>fire agate</td>
    <td></td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Gem">Gem</a></td>
    <td>turquoise</td>
    <td>1974</td>
  </tr>

* * * * *
// I WANT TO INSERT THE FOLLOWING STATIC ROW
<tr><td colspan="4" style="background: #009; color: #fff; text-align: center;"><strong>Cultural Symbols</strong></td></tr>
* * * * *

  <tr>
    <td><a href="/World/Arizona/Colors">Colors</a></td>
    <td>blue and gold</td>
    <td>1931</td>
  </tr>
  <tr>
    <td><a href="/World/Arizona/Neckwear">Neckwear</a></td>
    <td>bola tie</td>
    <td>1973</td>
  </tr>
</tbody>
</table>

Yikes, I’m afraid I’m lost with arrays; I just began working with them a few weeks ago and don’t really understand what you’re saying.

Maybe it will help if I give a basic overview, though. First, I have a database table that lists symbols of various nations and states. It probably needs to be modified, but it’s working pretty good so far.

One key row is URL, which simply lists each page’s URL, like Arizona/Flag or Arizona/Flower

Another key row is Symbol, which lists the name of each symbol, like “saguaro cactus blossom” for Arizona’s state flower. However, it doesn’t list names for flags or coats of arms, since they don’t have names.

Three other key rows…

DesigGroup - Values include Flags, Animals, Plants, Minerals, etc. This helps me organize everything into categories.

DesigGeneral - This helps me refine my classification, with values like Flowers, Trees, Fruit, etc.

Desig - If a flower is recognized as the “national flower,” then this value is null. However, if there’s a unique designation, like “Official Environmental Symbol,” then that’s the value.

The dynamic rows are displayed with several blocks of code…


// This displays plants, animals and minerals. Since the table is ordered by the numerical key, they actually appear in the middle of the table.
echo <<<EOD
   <tr class="$DesigGroup $Alternate" style="background-color:$c">
     <td class="$class"><a href="/World/$URL">$Check$DesigD</a>$ast</td>
     <td class="left">$Symbol</td>
     <td class="latin">$Latin</td>
     <td class="left">$Year</td>
   </tr>
EOD;

// The next two block display earth symbols, which are listed just after plants and animals...
switch ($DesigGen)
{
 case 'fossil':
// This displays fossils...
echo <<<EOD
   <tr class="{$row["DesigGroup"]} $Alternate" style="background-color:$c">
     <td class="$class"><a href="/World/$URL">$Check$DesigD</a>$ast</td>
     <td class="left">$Symbol</td>
     <td class="latin">$Latin</td>
     <td class="left">$Year</td>
   </tr>
EOD;

// This displays other earth symbols...
echo <<<EOD
   <tr class="{$row["DesigGroup"]} $Alternate" style="background-color:$c">
     <td class="$class"><a href="/World/$URL">$Check$DesigD</a>$ast</td>
     <td colspan="2" class="left">$Symbol</td>
     <td class="left">$Year</td>
   </tr>

// This displays mottoes...
switch ($DesigGen)
{
 case 'motto':
  // INTERNAL SWITCH
  switch ($row['Language'])
  {
   case '':
   $StyleS = '';
   $Language = '';
   break;
   default:
   $StyleS = ' style="font-style: oblique;"';
   $Language = '&nbsp;&nbsp;<span style="font-size: 85%; background: #009;">[<a href="/World/'.$MyName.'/Motto">('.$row['Language'].'...)</a>]</span>';
   break;
  }
  // END INTERNAL SWITCH
 break;
 default:
 $Language = '';
 break;
}

// And this displays all the other symbols, including "Top Symbols" (which appear at the top of the table) and "Cultural Symbols" (which appear at the end)....
echo <<<EOD
   <tr class="{$row["DesigGroup"]} $Alternate" style="background:$c">
     <td class="$class"><a href="/World/$URL">$Check$DesigD</a>$ast</td>
     <td colspan="2" class="left">$Symbol$Language</td>
     <td class="left">$Year</td>
   </tr>
EOD;

But like I said, I’ll probably modify my database table a bit before I get it all figured out. :wink:

From what you are saying, you are getting some data from mysql.

This will most likely be an array of results which you have to loop through judging by this comment in your OP:

I’m displaying a somewhat complex table inside a WHILE LOOP with the following code…

If you use var_export to output that array of results, and trim it down a bit if necessary so that it isnt reams of code but does typify your problem, then maybe someone can help you output that array into a simplified version of your table – to which you can then add the bells and whistles.

I mean, I think I understand your problem and I could generate an array of test values to show how to add these static rows as you call them, but you’d then face problems matching that to your own use case. Dealing with a typical subset of values which you are already grabbing from your db will be much easier for you to understand.

If you have problems understanding my var_export code,


echo var_export($yourMysqlResults, 1);

then just do this:


var_dump($yourMysqlResults);

… but the output of var_dump just means that in order to recreate your problem, or test any solutions some of us would have to type out the array again.

Some of us a much cleverer and can do all this stuff accurately in our heads, I am not one. :wink:

Oh, now I understand what you mean. OK, I posted your code inside the while loop and replaced $yourMysqlResults with $row. I got the following results for var_export:


array ( 0 => '3160', 'N' => '3160', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Flag', 'URL' => 'Arizona/Flag', 3 => 'Flag', 'PostURL' => 'Flag', 4 => 'Arizona&#8217;s State Flag', 'Title' => 'Arizona&#8217;s State Flag', 5 => '3', 'MyKind2' => '3', 6 => 'flag', 'DesigGen' => 'flag', 7 => 'Vex', 'DesigGroup' => 'Vex', 8 => '', 'Symbol' => '', 9 => '', 'Desig' => '', 10 => '', 11 => '1917', 'Date' => '1917', 12 => '', 'Common' => '', 13 => 'Olea_europaea', 'Latin' => 'Olea_europaea', 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Flag', 19 => '', 'Article' => '', ) array ( 0 => '3161', 'N' => '3161', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Seal', 'URL' => 'Arizona/Seal', 3 => 'Seal', 'PostURL' => 'Seal', 4 => 'Arizona&#8217;s State Seal', 'Title' => 'Arizona&#8217;s State Seal', 5 => '3', 'MyKind2' => '3', 6 => 'seal', 'DesigGen' => 'seal', 7 => 'Vex', 'DesigGroup' => 'Vex', 8 => '', 'Symbol' => '', 9 => '', 'Desig' => '', 10 => '', 11 => '1911', 'Date' => '1911', 12 => '', 'Common' => '', 13 => 'Olea_europaea', 'Latin' => 'Olea_europaea', 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Seal', 19 => '', 'Article' => '', ) array ( 0 => '3162', 'N' => '3162', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Nickname', 'URL' => 'Arizona/Nickname', 3 => 'Nickname', 'PostURL' => 'Nickname', 4 => 'Arizona&#8217;s Nicknames', 'Title' => 'Arizona&#8217;s Nicknames', 5 => '3', 'MyKind2' => '3', 6 => 'nickname', 'DesigGen' => 'nickname', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'The Grand Canyon State', 'Symbol' => 'The Grand Canyon State', 9 => '', 'Desig' => '', 10 => 'The Grand Canyon State', 11 => '', 'Date' => '', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Nickname', 19 => '', 'Article' => '', ) array ( 0 => '3163', 'N' => '3163', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Motto', 'URL' => 'Arizona/Motto', 3 => 'Motto', 'PostURL' => 'Motto', 4 => 'Arizona&#8217;s State Motto', 'Title' => 'Arizona&#8217;s State Motto', 5 => '3', 'MyKind2' => '3', 6 => 'motto', 'DesigGen' => 'motto', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'Ditat Deus', 'Symbol' => 'Ditat Deus', 9 => '', 'Desig' => '', 10 => 'Ditat Deus', 11 => '1864', 'Date' => '1864', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => 'Arizona/Motto', 'MottoURL' => 'Arizona/Motto', 15 => 'Latin', 'Language' => 'Latin', 16 => 'Ditat_Deus', 'Motto' => 'Ditat_Deus', 17 => 'us-az', 'ID' => 'us-az', 18 => 'Motto', 19 => '', 'Article' => '', ) array ( 0 => '3164', 'N' => '3164', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Song', 'URL' => 'Arizona/Song', 3 => 'Song', 'PostURL' => 'Song', 4 => 'Arizona&#8217;s State Anthem', 'Title' => 'Arizona&#8217;s State Anthem', 5 => '3', 'MyKind2' => '3', 6 => 'song', 'DesigGen' => 'song', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'Arizona March Song', 'Symbol' => 'Arizona March Song', 9 => 'Anthem', 'Desig' => 'Anthem', 10 => 'Arizona March Song', 11 => '1919', 'Date' => '1919', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Song', 19 => '', 'Article' => '', ) array ( 0 => '3165', 'N' => '3165', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Song2', 'URL' => 'Arizona/Song2', 3 => 'Song2', 'PostURL' => 'Song2', 4 => 'Arizona&#8217;s Alternate State Anthem', 'Title' => 'Arizona&#8217;s Alternate State Anthem', 5 => '3', 'MyKind2' => '3', 6 => 'song', 'DesigGen' => 'song', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'Arizona', 'Symbol' => 'Arizona', 9 => 'Alternate Anthem', 'Desig' => 'Alternate Anthem', 10 => 'Arizona', 11 => '1981', 'Date' => '1981', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Song2', 19 => '', 'Article' => '', ) array ( 0 => '3166', 'N' => '3166', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Flower', 'URL' => 'Arizona/Flower', 3 => 'Flower', 'PostURL' => 'Flower', 4 => 'Arizona&#8217;s State Flower', 'Title' => 'Arizona&#8217;s State Flower', 5 => '3', 'MyKind2' => '3', 6 => 'flower', 'DesigGen' => 'flower', 7 => 'Plants', 'DesigGroup' => 'Plants', 8 => 'saguaro cactus blossom', 'Symbol' => 'saguaro cactus blossom', 9 => '', 'Desig' => '', 10 => 'saguaro cactus blossom', 11 => '1931', 'Date' => '1931', 12 => 'saguaro cactus blossom', 'Common' => 'saguaro cactus blossom', 13 => 'Carnegia_gigantea', 'Latin' => 'Carnegia_gigantea', 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Flower', 19 => '

And this is what I got for var_dump. (I inserted “Hello World” to separate var_export from var_dump. However, I wound up with several blocks of code for var_dump. They look almost identical.)


array(38) { [0]=> string(4) "3160" ["N"]=> string(4) "3160" [1]=> string(5) "us-az" ["GID"]=> string(5) "us-az" [2]=> string(12) "Arizona/Flag" ["URL"]=> string(12) "Arizona/Flag" [3]=> string(4) "Flag" ["PostURL"]=> string(4) "Flag" [4]=> string(26) "Arizona&#8217;s State Flag" ["Title"]=> string(26) "Arizona&#8217;s State Flag" [5]=> string(1) "3" ["MyKind2"]=> string(1) "3" [6]=> string(4) "flag" ["DesigGen"]=> string(4) "flag" [7]=> string(3) "Vex" ["DesigGroup"]=> string(3) "Vex" [8]=> string(0) "" ["Symbol"]=> string(0) "" [9]=> string(0) "" ["Desig"]=> string(0) "" [10]=> string(0) "" [11]=> string(4) "1917" ["Date"]=> string(4) "1917" [12]=> string(0) "" ["Common"]=> string(0) "" [13]=> string(13) "Olea_europaea" ["Latin"]=> string(13) "Olea_europaea" [14]=> NULL ["MottoURL"]=> NULL [15]=> NULL ["Language"]=> NULL [16]=> NULL ["Motto"]=> NULL [17]=> string(5) "us-az" ["ID"]=> string(5) "us-az" [18]=> string(4) "Flag" [19]=> string(0) "" ["Article"]=> string(0) "" } array ( 0 => '3161', 'N' => '3161', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Seal', 'URL' => 'Arizona/Seal', 3 => 'Seal', 'PostURL' => 'Seal', 4 => 'Arizona&#8217;s State Seal', 'Title' => 'Arizona&#8217;s State Seal', 5 => '3', 'MyKind2' => '3', 6 => 'seal', 'DesigGen' => 'seal', 7 => 'Vex', 'DesigGroup' => 'Vex', 8 => '', 'Symbol' => '', 9 => '', 'Desig' => '', 10 => '', 11 => '1911', 'Date' => '1911', 12 => '', 'Common' => '', 13 => 'Olea_europaea', 'Latin' => 'Olea_europaea', 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Seal', 19 => '', 'Article' => '', )

Hello World!

array(38) { [0]=> string(4) "3161" ["N"]=> string(4) "3161" [1]=> string(5) "us-az" ["GID"]=> string(5) "us-az" [2]=> string(12) "Arizona/Seal" ["URL"]=> string(12) "Arizona/Seal" [3]=> string(4) "Seal" ["PostURL"]=> string(4) "Seal" [4]=> string(26) "Arizona&#8217;s State Seal" ["Title"]=> string(26) "Arizona&#8217;s State Seal" [5]=> string(1) "3" ["MyKind2"]=> string(1) "3" [6]=> string(4) "seal" ["DesigGen"]=> string(4) "seal" [7]=> string(3) "Vex" ["DesigGroup"]=> string(3) "Vex" [8]=> string(0) "" ["Symbol"]=> string(0) "" [9]=> string(0) "" ["Desig"]=> string(0) "" [10]=> string(0) "" [11]=> string(4) "1911" ["Date"]=> string(4) "1911" [12]=> string(0) "" ["Common"]=> string(0) "" [13]=> string(13) "Olea_europaea" ["Latin"]=> string(13) "Olea_europaea" [14]=> NULL ["MottoURL"]=> NULL [15]=> NULL ["Language"]=> NULL [16]=> NULL ["Motto"]=> NULL [17]=> string(5) "us-az" ["ID"]=> string(5) "us-az" [18]=> string(4) "Seal" [19]=> string(0) "" ["Article"]=> string(0) "" } array ( 0 => '3162', 'N' => '3162', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Nickname', 'URL' => 'Arizona/Nickname', 3 => 'Nickname', 'PostURL' => 'Nickname', 4 => 'Arizona&#8217;s Nicknames', 'Title' => 'Arizona&#8217;s Nicknames', 5 => '3', 'MyKind2' => '3', 6 => 'nickname', 'DesigGen' => 'nickname', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'The Grand Canyon State', 'Symbol' => 'The Grand Canyon State', 9 => '', 'Desig' => '', 10 => 'The Grand Canyon State', 11 => '', 'Date' => '', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Nickname', 19 => '', 'Article' => '', )

Hello World!

array(38) { [0]=> string(4) "3162" ["N"]=> string(4) "3162" [1]=> string(5) "us-az" ["GID"]=> string(5) "us-az" [2]=> string(16) "Arizona/Nickname" ["URL"]=> string(16) "Arizona/Nickname" [3]=> string(8) "Nickname" ["PostURL"]=> string(8) "Nickname" [4]=> string(25) "Arizona&#8217;s Nicknames" ["Title"]=> string(25) "Arizona&#8217;s Nicknames" [5]=> string(1) "3" ["MyKind2"]=> string(1) "3" [6]=> string(8) "nickname" ["DesigGen"]=> string(8) "nickname" [7]=> string(3) "Top" ["DesigGroup"]=> string(3) "Top" [8]=> string(22) "The Grand Canyon State" ["Symbol"]=> string(22) "The Grand Canyon State" [9]=> string(0) "" ["Desig"]=> string(0) "" [10]=> string(22) "The Grand Canyon State" [11]=> string(0) "" ["Date"]=> string(0) "" [12]=> NULL ["Common"]=> NULL [13]=> NULL ["Latin"]=> NULL [14]=> NULL ["MottoURL"]=> NULL [15]=> NULL ["Language"]=> NULL [16]=> NULL ["Motto"]=> NULL [17]=> string(5) "us-az" ["ID"]=> string(5) "us-az" [18]=> string(8) "Nickname" [19]=> string(0) "" ["Article"]=> string(0) "" } array ( 0 => '3163', 'N' => '3163', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Motto', 'URL' => 'Arizona/Motto', 3 => 'Motto', 'PostURL' => 'Motto', 4 => 'Arizona&#8217;s State Motto', 'Title' => 'Arizona&#8217;s State Motto', 5 => '3', 'MyKind2' => '3', 6 => 'motto', 'DesigGen' => 'motto', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'Ditat Deus', 'Symbol' => 'Ditat Deus', 9 => '', 'Desig' => '', 10 => 'Ditat Deus', 11 => '1864', 'Date' => '1864', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => 'Arizona/Motto', 'MottoURL' => 'Arizona/Motto', 15 => 'Latin', 'Language' => 'Latin', 16 => 'Ditat_Deus', 'Motto' => 'Ditat_Deus', 17 => 'us-az', 'ID' => 'us-az', 18 => 'Motto', 19 => '', 'Article' => '', )

Hello World!

array(38) { [0]=> string(4) "3163" ["N"]=> string(4) "3163" [1]=> string(5) "us-az" ["GID"]=> string(5) "us-az" [2]=> string(13) "Arizona/Motto" ["URL"]=> string(13) "Arizona/Motto" [3]=> string(5) "Motto" ["PostURL"]=> string(5) "Motto" [4]=> string(27) "Arizona&#8217;s State Motto" ["Title"]=> string(27) "Arizona&#8217;s State Motto" [5]=> string(1) "3" ["MyKind2"]=> string(1) "3" [6]=> string(5) "motto" ["DesigGen"]=> string(5) "motto" [7]=> string(3) "Top" ["DesigGroup"]=> string(3) "Top" [8]=> string(19) "Ditat Deus" ["Symbol"]=> string(19) "Ditat Deus" [9]=> string(0) "" ["Desig"]=> string(0) "" [10]=> string(19) "Ditat Deus" [11]=> string(4) "1864" ["Date"]=> string(4) "1864" [12]=> NULL ["Common"]=> NULL [13]=> NULL ["Latin"]=> NULL [14]=> string(13) "Arizona/Motto" ["MottoURL"]=> string(13) "Arizona/Motto" [15]=> string(5) "Latin" ["Language"]=> string(5) "Latin" [16]=> string(10) "Ditat_Deus" ["Motto"]=> string(10) "Ditat_Deus" [17]=> string(5) "us-az" ["ID"]=> string(5) "us-az" [18]=> string(5) "Motto" [19]=> string(0) "" ["Article"]=> string(0) "" } array ( 0 => '3164', 'N' => '3164', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Song', 'URL' => 'Arizona/Song', 3 => 'Song', 'PostURL' => 'Song', 4 => 'Arizona&#8217;s State Anthem', 'Title' => 'Arizona&#8217;s State Anthem', 5 => '3', 'MyKind2' => '3', 6 => 'song', 'DesigGen' => 'song', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'Arizona March Song', 'Symbol' => 'Arizona March Song', 9 => 'Anthem', 'Desig' => 'Anthem', 10 => 'Arizona March Song', 11 => '1919', 'Date' => '1919', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Song', 19 => '', 'Article' => '', )

Hello World!

array(38) { [0]=> string(4) "3164" ["N"]=> string(4) "3164" [1]=> string(5) "us-az" ["GID"]=> string(5) "us-az" [2]=> string(12) "Arizona/Song" ["URL"]=> string(12) "Arizona/Song" [3]=> string(4) "Song" ["PostURL"]=> string(4) "Song" [4]=> string(28) "Arizona&#8217;s State Anthem" ["Title"]=> string(28) "Arizona&#8217;s State Anthem" [5]=> string(1) "3" ["MyKind2"]=> string(1) "3" [6]=> string(4) "song" ["DesigGen"]=> string(4) "song" [7]=> string(3) "Top" ["DesigGroup"]=> string(3) "Top" [8]=> string(18) "Arizona March Song" ["Symbol"]=> string(18) "Arizona March Song" [9]=> string(6) "Anthem" ["Desig"]=> string(6) "Anthem" [10]=> string(18) "Arizona March Song" [11]=> string(4) "1919" ["Date"]=> string(4) "1919" [12]=> NULL ["Common"]=> NULL [13]=> NULL ["Latin"]=> NULL [14]=> NULL ["MottoURL"]=> NULL [15]=> NULL ["Language"]=> NULL [16]=> NULL ["Motto"]=> NULL [17]=> string(5) "us-az" ["ID"]=> string(5) "us-az" [18]=> string(4) "Song" [19]=> string(0) "" ["Article"]=> string(0) "" } array ( 0 => '3165', 'N' => '3165', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Song2', 'URL' => 'Arizona/Song2', 3 => 'Song2', 'PostURL' => 'Song2', 4 => 'Arizona&#8217;s Alternate State Anthem', 'Title' => 'Arizona&#8217;s Alternate State Anthem', 5 => '3', 'MyKind2' => '3', 6 => 'song', 'DesigGen' => 'song', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'Arizona', 'Symbol' => 'Arizona', 9 => 'Alternate Anthem', 'Desig' => 'Alternate Anthem', 10 => 'Arizona', 11 => '1981', 'Date' => '1981', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Song2', 19 => '', 'Article' => '', )

Hello World!

array(38) { [0]=> string(4) "3165" ["N"]=> string(4) "3165" [1]=> string(5) "us-az" ["GID"]=> string(5) "us-az" [2]=> string(13) "Arizona/Song2" ["URL"]=> string(13) "Arizona/Song2" [3]=> string(5) "Song2" ["PostURL"]=> string(5) "Song2" [4]=> string(38) "Arizona&#8217;s Alternate State Anthem" ["Title"]=> string(38) "Arizona&#8217;s Alternate State Anthem" [5]=> string(1) "3" ["MyKind2"]=> string(1) "3" [6]=> string(4) "song" ["DesigGen"]=> string(4) "song" [7]=> string(3) "Top" ["DesigGroup"]=> string(3) "Top" [8]=> string(7) "Arizona" ["Symbol"]=> string(7) "Arizona" [9]=> string(16) "Alternate Anthem" ["Desig"]=> string(16) "Alternate Anthem" [10]=> string(7) "Arizona" [11]=> string(4) "1981" ["Date"]=> string(4) "1981" [12]=> NULL ["Common"]=> NULL [13]=> NULL ["Latin"]=> NULL [14]=> NULL ["MottoURL"]=> NULL [15]=> NULL ["Language"]=> NULL [16]=> NULL ["Motto"]=> NULL [17]=> string(5) "us-az" ["ID"]=> string(5) "us-az" [18]=> string(5) "Song2" [19]=> string(0) "" ["Article"]=> string(0) "" } array ( 0 => '3166', 'N' => '3166', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Flower', 'URL' => 'Arizona/Flower', 3 => 'Flower', 'PostURL' => 'Flower', 4 => 'Arizona&#8217;s State Flower', 'Title' => 'Arizona&#8217;s State Flower', 5 => '3', 'MyKind2' => '3', 6 => 'flower', 'DesigGen' => 'flower', 7 => 'Plants', 'DesigGroup' => 'Plants', 8 => 'saguaro cactus blossom', 'Symbol' => 'saguaro cactus blossom', 9 => '', 'Desig' => '', 10 => 'saguaro cactus blossom', 11 => '1931', 'Date' => '1931', 12 => 'saguaro cactus blossom', 'Common' => 'saguaro cactus blossom', 13 => 'Carnegia_gigantea', 'Latin' => 'Carnegia_gigantea', 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Flower', 19 => '

P.S. Thanks for the code; I can see how it might be useful for troubleshooting. For example, I found one value that shouldn’t even be listed - Olea_europea.

Ok, I’m glad you’ve learned how to really peer inside your array using var_dump(), you will use this ALL THE TIME not only to look at arrays, but to check the value and the type of all kinds of variables that you create.

The reason to use var_export is so that instead of typing out your array by hand, I can just copy and paste it and then start using it. That means you will get help faster when asking Qs about arrays.

I indented this first array, is this really what you expected from your db query? The next 4 are there too.

You have both numerical keys and string keys containing the same data?


// this is your result set, I think
$rows =
array( 0 =>
 array ( 
0 => '3160',
 'N' => '3160', 
1 => 'us-az',
'GID' => 'us-az', 
2 => 'Arizona/Flag', 
'URL' => 'Arizona/Flag', 
3 => 'Flag', 
'PostURL' => 'Flag', 
4 => 'Arizonas State Flag', 
'Title' => 'Arizonas State Flag', 
5 => '3', 
'MyKind2' => '3', 
6 => 'flag',
 'DesigGen' => 'flag', 
7 => 'Vex', 
'DesigGroup' => 'Vex', 
8 => '', 
'Symbol' => '', 
9 => '', 
'Desig' => '', 
10 => '', 
11 => '1917', 
'Date' => '1917', 
12 => '',
 'Common' => '', 
13 => 'Olea_europaea',
'Latin' => 'Olea_europaea', 
14 => NULL, 
'MottoURL' => NULL, 
15 => NULL, 
'Language' => NULL, 
16 => NULL, 
'Motto' => NULL, 
17 => 'us-az', 
'ID' => 'us-az', 
18 => 'Flag', 
19 => '', 
'Article' => '', ),

1 => 

array ( 0 => '3161', 'N' => '3161', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Seal', 'URL' => 'Arizona/Seal', 3 => 'Seal', 'PostURL' => 'Seal', 4 => 'Arizona State Seal', 5 => '3', 'MyKind2' => '3', 6 => 'seal', 'DesigGen' => 'seal', 7 => 'Vex', 'DesigGroup' => 'Vex', 8 => '', 'Symbol' => '', 9 => '', 'Desig' => '', 10 => '', 11 => '1911', 'Date' => '1911', 12 => '', 'Common' => '', 13 => 'Olea_europaea', 'Latin' => 'Olea_europaea', 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Seal', 
19 => '', 'Article' => '', ) 
, 2 =>
array ( 0 => '3162', 'N' => '3162', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Nickname', 'URL' => 'Arizona/Nickname', 3 => 'Nickname', 'PostURL' => 'Nickname', 4 => 'Arizonas Nicknames', 'Title' => 'Arizona Nicknames', 5 => '3', 'MyKind2' => '3', 6 => 'nickname', 'DesigGen' => 'nickname', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'The Grand Canyon State', 'Symbol' => 'The Grand Canyon State', 9 => '', 'Desig' => '', 10 => 'The Grand Canyon State', 11 => '', 'Date' => '', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Nickname', 19 => '', 'Article' => '', ) 
, 3=>
array ( 0 => '3163', 'N' => '3163', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Motto', 'URL' => 'Arizona/Motto', 3 => 'Motto', 'PostURL' => 'Motto', 4 => 'ArizonaState Motto', 'Title' => 'Arizonas State Motto', 5 => '3', 'MyKind2' => '3', 6 => 'motto', 'DesigGen' => 'motto', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'Ditat Deus', 'Symbol' => 'Ditat Deus', 9 => '', 'Desig' => '', 10 => 'Ditat Deus', 11 => '1864', 'Date' => '1864', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => 'Arizonas Motto', 'MottoURL' => 'Arizona/Motto', 15 => 'Latin', 'Language' => 'Latin', 16 => 'Ditat_Deus', 'Motto' => 'Ditat_Deus', 17 => 'us-az', 'ID' => 'us-az', 18 => 'Motto', 19 => '', 'Article' => '', ) 
,4 =>
array ( 0 => '3164', 'N' => '3164', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Song', 'URL' => 'Arizona/Song', 3 => 'Song', 'PostURL' => 'Song', 4 => 'Arizona State Anthem', 'Title' => 'Arizonas State Anthem', 5 => '3', 'MyKind2' => '3', 6 => 'song', 'DesigGen' => 'song', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'Arizona March Song', 'Symbol' => 'Arizona March Song', 9 => 'Anthem', 'Desig' => 'Anthem', 10 => 'Arizona March Song', 11 => '1919', 'Date' => '1919', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Song', 19 => '', 'Article' => '', ) 
, 5 =>
array ( 0 => '3165', 'N' => '3165', 1 => 'us-az', 'GID' => 'us-az', 2 => 'Arizona/Song2', 'URL' => 'Arizona/Song2', 3 => 'Song2', 'PostURL' => 'Song2', 4 => 'Arizonas Alternate State Anthem', 'Title' => 'Arizonas Alternate State Anthem', 5 => '3', 'MyKind2' => '3', 6 => 'song', 'DesigGen' => 'song', 7 => 'Top', 'DesigGroup' => 'Top', 8 => 'Arizona', 'Symbol' => 'Arizona', 9 => 'Alternate Anthem', 'Desig' => 'Alternate Anthem', 10 => 'Arizona', 11 => '1981', 'Date' => '1981', 12 => NULL, 'Common' => NULL, 13 => NULL, 'Latin' => NULL, 14 => NULL, 'MottoURL' => NULL, 15 => NULL, 'Language' => NULL, 16 => NULL, 'Motto' => NULL, 17 => 'us-az', 'ID' => 'us-az', 18 => 'Song2', 19 => '', 'Article' => '', ) 
);

var_dump($rows);


Are these typical rows?

That looks 95% correct. It displays information for an article about Arizona’s state flag at Arizona/Flag, row #3160 in my database table, and flags are correctly classified as DesigGroup = “Vex”, DesigGen = “flag.” Arizona’s flag was adopted in 1917.

However, I’m not sure why the 12th value, “Common,” is there, and the last one - “Olea_europea” - doesn’t belong there at all.

Part of the problem is that I’ve joined several tables and am displaying information for symbols that are very different. For example, national flowers and birds have both common names and scientific names, while flags have neither.

But the data is displaying surprisingly well in general. I just have a few modifications to make.