SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist
    Join Date
    Nov 2003
    Location
    Brisbane, Australia
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems phasing an array content

    Hi All

    I am building a side nav using an array. It works fine if I use html as the output but I want to add an if/else statement. Below is my code.

    I know the if/else statement will work if it is running independently but I cannot/I don't know how to phase my if/else as php in the output.

    Any help would be greatly appreciated.

    mrmbarnes

    PHP Code:
    <?php
       
    // initialization
        
    $result_array = array();
        
    $counter 0;

        
    $PID = (int)($_GET['PID4']);

    // Category Listing

        
    if( empty($PID))
        {
            
    $result mysql_query"SELECT navid, text, link
                            FROM nav
                            ORDER BY navid asc
                            " 
    );
            while( 
    $row mysql_fetch_array$result ) )
            {
                
    $result_array[] = "
                              if ("
    .$_SERVER['REQUEST_URI']." == '/".$row[2]."') {
          echo('&nbsp;<img src='/images/2dots.gif' width='8' height='8' align='absmiddle'>&nbsp;<span class='whitetext'>"
    .$row[1]."</span><br>
                        <img src='/images/spacer.gif' alt='' border='0' width='1' height='10'><br>
                        '); 
      }   else {
          echo('&nbsp;<img src='/images/2dots.gif' width='8' height='8' align='absmiddle'>&nbsp;<a href='"
    .$row[2]."'>".$row[1]."</a><br>
                        <img src='/images/spacer.gif' alt='' border='0' width='1' height='10'><br>');
      }

          "
    ;
            }
            
    mysql_free_result$result );    

            
    $result_final "";

            foreach(
    $result_array as $page_link)
            {
                if(
    $counter == $number_of_categories_in_row)
                {    
                    
    $counter 1;
                    
    $result_final .= "";
                }
                else
                
    $counter++;

                
    $result_final .= "".$page_link."";
            }

        }
        echo (
    "
                <table width='100%' border='0' cellspacing='2' cellpadding='2'>
                  <tr>
                    <td>
                      <p>
                        <img src='/images/spacer.gif' alt='' border='0' width='1' height='10'><br>"
    );
                        eval(
    '?>' $result_final);
                      echo (
    "</p>
                    </td>
                  </tr>
                </table>
    "
    );
    ?>

  2. #2
    SitePoint Evangelist
    Join Date
    Nov 2003
    Location
    Brisbane, Australia
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi All

    I could really do with some help with this.

    Many Thanks

    mrmbarnes

  3. #3
    SitePoint Evangelist
    Join Date
    Nov 2003
    Location
    Brisbane, Australia
    Posts
    408
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone??????


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •