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

  • SEARCH
  • Home
  • 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 7812685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:35:38+00:00 2026-06-02T04:35:38+00:00

I have 2 separate foreach loops being executed in the following code. At the

  • 0

I have 2 separate foreach loops being executed in the following code. At the end I have $row->websiteURL outputting right after the second foreach loop. The problem is $row->websiteURL is part of the first loop. So I get the following error when I run the code:

A PHP Error was encountered

Severity: Notice

Message: Undefined property: stdClass::$websiteURL

Filename: views/projects.php

Line Number: 135

” target=”_blank”>

How would I go about continuing the first foreach loop after the second foreach is complete?

<table style="width: 41%">
<?php   $query  = $this->db->query("SELECT * FROM projects ORDER BY idprojects DESC");
        foreach ($query->result() as $row) { ?>
    <tr>
        <td style="height: 15px">
        <div class="auto-style2">
            <em><span class="auto-style1"><?=$row->projectName?></span></div>
        <table cellpadding="5" style="width: 535px; height: 66;">
            <tr>
                <td class="box1" style="height: 49px; width: 800px;">
        <table cellpadding="0" cellspacing="0" style="width: 466px; height: 185px">
            <!-- MSTableType="layout" -->
            <tr>
                <td valign="top" style="width: 225px">
            <em>
        <table style="width: 100%">
            <tr class="box1">
                <td class="innerbox" style="height: 88px"><em><span class="text1">Project name</span>:
                <span class="underlined-link"><?=$row->projectName?></span><br>
                <span class="text1">Description</span>: <?=$row->projectDesc?><br><span class="text1">Start 
                date</span>: <?=$row->startDate?><br><span class="text1">Finised date</span>: 
                <?=$row->finishedDate?><br><span class="text1">Created for</span>: 
                <?=$row->createdFor?><br><span class="text1">Contributers</span>:
                <span class="underlined-link"><?=$row->contributors?></span></em></td>
            </tr>
        </table>
        </em></td>
                <td style="width: 12px">&nbsp;</td>
                <td valign="top" style="height: 185px; width: 229px">
            <em>
<?php           $query  = $this->db->query("SELECT * FROM screenshots ORDER BY idscreenshot DESC");
                foreach ($query->result() as $row) { ?>
                <img alt="" src="<?=$row->screenshotURI?>" width="231" height="187"></em>&nbsp;</td>
            </tr>
<?php } ?>
        </table>
                <br>
                <a style="text-decoration:none" href="<?=$row->websiteURL?>" target="_blank"><div class="link1">
                    View This Product</div></a>
                </td>
            </tr>
        </table>
        </em></td>
    </tr>
<?php } ?>
        </table>
  • 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-02T04:35:39+00:00Added an answer on June 2, 2026 at 4:35 am

    You need to change your variables in the second foreach like this:

     $query  = $this->db->query("SELECT * FROM screenshots ORDER BY idscreenshot DESC");
                    foreach ($query->result() as $row2) { ?>
                    <img alt="" src="<?=$row2->screenshotURI?>" width="231" height="187"></em>&nbsp;</td>
    

    The $row variable is still in scope and it’s looking in the first query for this. If you are doing an inner foreach loop you can’t name the “item” variable the same as the outter foreach.

    so more to the point:

    foreach($arr as $row):
       foreach($arr as $row2):
          //do something
       endforeach;
     endforeach;
    

    Back to the bigger issue. You should not being querying data in the views. Data is manipulated in the Model. The controller loads the model, uses the model to get the information, then passes the info to the view. It can be a difficult concept to grasp if you’re new to MVC. Once you get this working, focus on moving these queries into their own functions in your model and retrieving the information that way.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi all fellow programmer I'd like to have a separate js file for each
I have an object that has 3 separate Dictionaries. The value parameter for each
Do I need to have separate/multiple workers to run multiple websites (each with a
What's the best way to have separate CSS for IE and other browsers? I'm
In my ASP.NET application I have separate projects for the Data, Business and UI
I have web application which we deployed in a production . We have separate
I use subversion to manage my yii website (php framework) and have separate backend
I am trying to integrate CAS on Liferay. I have separate CAS server running
We have two separate web-apps, say 'retailUI' and 'bulkUI'. These two are basically two
I have three separate applications A, B and C. All of them use service

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.