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 5957023
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:20:29+00:00 2026-05-22T18:20:29+00:00

i am trying to get my data from the database and wrap it with

  • 0

i am trying to get my data from the database and wrap it with html tags. here is the working code so far:

function homethumb(){ $this->count; $i = 0;
   while($row = mysqli_fetch_object($this->result))
   {
      $this->count++; $i++;
      if($i == 1){echo '<div class="gal1">';}
      echo '<a href="portfolio.php?id=' . $row->id . '"> <div class="gal"><img src="img/' . $row->thumb2 . '.jpg"></div></a>';
      if($i == 2){
      echo '</div> <!-- gal1 -->';
      $i=0;
      } 
   }
}

Here I am getting everything from the database (Select * from portfolio), but in the portfolio I have, websites, demos and graphics; so I wanted to get only the data where category = “web” from the above code, so I tried this:

function homethumb(){ $this->count; $i = 0;
   while($row = mysqli_fetch_object($this->result))
   {
      if($row->category = "web"){
               $this->count++; $i++;
         if($i == 1){echo '<div class="gal1">';}
         echo '<a href="portfolio.php?id=' . $row->id . '"> <div class="gal"><img src="img/' . $row->thumb2 . '.jpg"></div></a>';
         if($i == 2){
         echo '</div> <!-- gal1 -->';
         $i=0;
         } 
      }
   }
}

now the nested if statements do not generate the divs I need, how can I get this working

thanks for your help

  • 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-05-22T18:20:30+00:00Added an answer on May 22, 2026 at 6:20 pm

    I can’t see your SQL based on your question, but you could just modify your SELECT query to include WHERE category="web"

    This way, you’re only selecting the rows you need, instead of looping over every row in that table.

    Additionally, it appears that you’re using assignment = instead of comparison == for your if statement.

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

Sidebar

Related Questions

I am trying to get data from a database. I have the following code
I am trying to get the data from database by using the below code.....
Actually i was trying to get data from elgg database based on multiple joins.
for example I'm trying to get the data from database like: using (ExplorerDataContext context
I am trying to get some data from a database on the fly and
I'm trying to get data from database, and echo them on the page using
I'm trying to get data from the database in order to create a list
I'm trying to get data from a database using FMDB but having tried with
I'm trying to get data from another database using the OPENDATASOURCE command, but I
I am trying get the data from my database but i am not getting

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.