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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:07:27+00:00 2026-05-26T14:07:27+00:00

$selectra_result = mysql_query(SELECT * FROM `my_selectra` WHERE user_id=’$user_id’) or die(mysql_error()); while($row = mysql_fetch_array( $selectra_result

  • 0
$selectra_result = mysql_query("SELECT * FROM `my_selectra` WHERE user_id='$user_id'") or die(mysql_error()); 

while($row = mysql_fetch_array( $selectra_result )) { 
     $product_id = $row['product_id']; 
     $namep[] = $product_name= $row['product_name'];
     $linkp[] = $product_permalink = $row['product_permalink'];
     $imgpp[] = $product_image_path = $row['product_image_path'];    
}

     foreach($namep as $pname => $prodname){
        foreach($linkp as $plink => $prodlink) {
         foreach($imgpp as $ppath => $prodpath) {

        $res1 = "<a href='$prodlink'><p>$prodname</p></a>";
        $res2 = "<a href='$prodlink'><img src='$prodpath'/>";

            }
        }     
      }
      echo $res2.''.$res1;

}

I want to display data from my_selectra table using foreach, unfortunately it appears only one data when echo.

  • 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-26T14:07:28+00:00Added an answer on May 26, 2026 at 2:07 pm

    Your code is pretty convoluted… You don’t need 3 arrays to grab the data you want, nor do you need a triple-nested foreach loop structure. Try something like this:

    $results = array();
    while($row = mysql_fetch_array( $selectra_result)) 
    { 
         $product_id = $row['product_id']; 
         $results[] = array( $row['product_name'], $row['product_permalink'], $row['product_image_path']);
    }
    
    $res1 = $res2 = '';
    foreach( $results as $row)
    {
        $res1 .= "<a href='" . $row[1] . "'><p>" . $row[0] . "</p></a>";
        $res2 .= "<a href='" . $row[1] . "'><img src='" . $row[2] . "'/>";
    }
    echo $res1 . $res2;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In SQL you can selecta constant value: Select Constant Text, Column1, Column2 From TableX
I have 2 select options. I want to change the drop down options in
I create a dropdown list by using ASP.NET MVC helper like this, <%=Html.DropDownList(Group,-please select
Let's say I have a table like this with multiple selects in very row:
Yesterday or the day before I got some help with a drop down select
I am attempting to translate or convert these functions from a .asp file into
In Objective-C you can pass a method A as a parameter of other method
I have an insert that uses a condition checking for a NOT IN. There
Currently, I have two drop down lists that are populated with users' first and
I have a form which changes the inputfields depending on a radio-button. for text

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.