Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8610521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:09:05+00:00 2026-06-12T04:09:05+00:00

Writing my first php application. I’m stuck on how to add either a loop

  • 0

Writing my first php application. I’m stuck on how to add either a loop or conditional statement…I’m adding my sites navigation from Oracle database queries…a primary and secondary navigation…I’ve noted in my code where I need an if or while statement to decide if a ul tag is written. I only want the ul class = sub tag written and subsequent li list when I have secondary navigation under the primary navigation. Any suggestion that would point me in the right direction? Thanks in advance…

`

        $t1_query = "SELECT * FROM PLUS_NAV_T1 ORDER BY POSITION ASC";
        $t1_parse = oci_parse($sm_conn, $t1_query);
        oci_execute ($t1_parse);
        /* Add query error catch*/

        while ($t1_row = oci_fetch_array($t1_parse, OCI_ASSOC)) {
            echo "<li><a href=\"#\" title=\"\" class=\"exp\"><span>{$t1_row["T1_NAME"]}</span></a>";

                $t2_query = "SELECT * FROM PLUS_NAV_T2 WHERE T1_ID_FK = {$t1_row["ID_PK"]} ORDER BY POSITION ASC ";
                $t2_parse = oci_parse($sm_conn, $t2_query);
                oci_execute ($t2_parse);
                /* Add query error catch*/

                /*Need a conditional here so ul tag is only written when the primary nav has secondary nav*/
                    echo "<ul class=\"sub\">";
                    while ($t2_row = oci_fetch_array($t2_parse, OCI_ASSOC)) {
                        echo "<li><a href=\"#\" title=\"\" style=\"color\">{$t2_row["T2_NAME"]}</a></li>";
                    }
                    echo "</ul>";

            echo "</li>";
        }

`

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T04:09:07+00:00Added an answer on June 12, 2026 at 4:09 am

    I’m not familiar with the Oracle driver, but you probably want the oci_num_rows() function. After you issue the second query, you should be able to call that function, and check if it returns a non-zero value:

    if (oci_num_rows($t2_parse)) {
        // your code to output the UL
    }
    

    Actually, you should probably also verify that oci_execute() returns true, so maybe something like:

    if (oci_execute($t2_parse) && oci_num_rows($t2_parse)) {
        // ...
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently writing my truly first PHP Application and i would like to
Im writing my first online shop in PHP. Now working on add product form
I started writing my first Zend Framework 2.0 (beta 1) PHP application using php
I will be writing my first daemon in php and I have a couple
This is my first question :). Im writing a little twitter app in PHP
Writing my first C# application...never touched the language before and not much of a
i'm writing my first MATLAB O-O application and i'm confused about the implementation of
So i am writing my first Java application using MVP pattern. One of MVPs
I'm not getting how can serialize help me in writing efficient PHP application .
I'm writing my first web application (still!), and have a problem activating user accounts.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.