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

The Archive Base Latest Questions

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

I have a php script that takes the individual characters entered into a form

  • 0

I have a php script that takes the individual characters entered into a form as the input to a mysql query and then loops through the resulting array with foreach to echo one image of artwork representing each of these characters (i.e. six images for f-l-o-w-e-r).

But how do I create a second echo within the same foreach such that the next div after each inputted letter is populated with the entire portfolio of just that letter alone (e.g. six records of images for letter “r” in db). As I currently have it, each div is populated with the portfolios of all characters inputted. How do I get it so the div after the letter r will be only six images of the letter “r”?

Thanks for any help! I’m new to all this scripting stuff in the past few weeks, so go easy on me. I really appreciate any insight.

$lettertype = str_split($lettertype);  
$lettertype = "'" . implode("','", $lettertype) . "'";       
$query = "SELECT * FROM Photos WHERE letter IN ($lettertype)"; 
$result = mysqli_query($cxn, $query) 
  or    die ("No good");    
$alpharray = array(); 
while($row = mysqli_fetch_assoc($result)){
    $alpharray[$row['letter']][] = $row; 
}
foreach(str_split($_POST['search_term']) as $alpha){          
    echo "<img class='clickable' img src='../Letterproject/images/{$alpharray[$alpha][0]['photoPath']}' width='100' height='140'></src>";          
    echo '<div class="editimages">';                     
    foreach ($alpharray as $tempvar){                   
        foreach($tempvar as $oneletter){                       
            echo "<img class='editable' img src='../Letterproject/images/{$oneletter['photoPath']}' width='100' height='140'></src>";                                      
        }
    }              
    echo '</div>';         
}
  • 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-26T21:40:07+00:00Added an answer on May 26, 2026 at 9:40 pm

    Tell me if that works. I changed the last foreach to do a foreach for every letterpicture there is. (assumes multiple results come back from the query for each letter)

    "SELECT * FROM Photos WHERE letter IN ($lettertype)"; 
    

    Anyways here it is.

    $lettertype = str_split($lettertype);  
    $lettertype = "'" . implode("','", $lettertype) . "'";       
    $query = "SELECT * FROM Photos WHERE letter IN ($lettertype)"; 
    $result = mysqli_query($cxn, $query) 
      or    die ("No good");    
    $alpharray = array(); 
    while($row = mysqli_fetch_assoc($result)){
        $alpharray[$row['letter']][] = $row; 
    }
    foreach(str_split($_POST['search_term']) as $alpha){          
        echo "<img class='clickable' img src='../Letterproject/images/{$alpharray[$alpha][0]['photoPath']}' width='100' height='140'></src>";          
        echo '<div class="editimages">';                     
        foreach ($alpharray[$alpha] as $tempvar){                                      
                echo "<img class='editable' img src='../Letterproject/images/{$tempvar['photoPath']}' width='100' height='140'></src>";                                      
        }              
        echo '</div>';         
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple PHP mailer script that takes values from a form submitted
I have a php script that takes hierarchical data from a mysql procedure and
I have a PHP script that simply takes some data, separates it into tab
I have a php pipe script that receives an email, takes an attached *.csv
I have a PHP script that initialises an image gallery. It loops through all
I have a php script that sends SMS, the problem is that it takes
I have a PHP script that takes about 10 minutes to complete. I want
I have a PHP script that takes a few minutes to finish processing. While
I have a PHP script that runs once a day, and it takes a
I have a PHP script running that's taking hours, it usually takes a long

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.