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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:27:02+00:00 2026-05-27T09:27:02+00:00

I have a query that selects all the information from a database table and

  • 0

I have a query that selects all the information from a database table and puts it into an array. I then use a PHP foreach statement to display all that in a uniform manner. It’s the left table here to get a sense of what I’m talking about.

What I want to do is to make one of the divs (it normally just appears repeatedly under the same name) to have a unique name for each sumbission row. For example, instead of the “response” divs all just being called response, they are “response1”, “response2”, and so on. Is there any way to do this? (code below)

Any help would be greatly appreciated.

Here’s where I call the info from the query:

<?php foreach($images as $image) { ?>

<table id="front_pgs">

<tr>
<td id="front_text">
<div id="imagetitle">
<?php echo $image['name'];?>
</div>
<div id="submission_info">  
submitted by <?php echo $image['submitter'];?>
</div>
<div id="ratingcontainer">    
<form id="ratingform">   
<input name="vote" type="button" onclick="getVote('<?php echo $image['filename'];?>')" value='Like' id="likebutton"/> 
<input name="dislike" type="button" value='Disike' id="dislikebutton"/> 
</form>


<div id="rate_count">
<div id="response">

<?php echo $image['rating'];?>

</div>
</div>
</div>
</td>
<td id="front_pg_img" valign="center" align="center">
<a onClick="switchImageUrl('<?php echo $image['filename']; ?>', '<?php echo $image['width']; ?>', '<?php echo $image['height']; ?>')"><img src="<?php echo $image['filename'];?>" id="front_pg_thumbnail"/></a>
</td>
</tr>
</table>

<?php } ?>
  • 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-27T09:27:03+00:00Added an answer on May 27, 2026 at 9:27 am
    <?php $i = 1; foreach($images as $image) { ?>
    
    <table id="front_pgs">
    
    <tr>
    <td id="front_text">
    <div id="imagetitle">
    <?php echo $image['name'];?>
    </div>
    <div id="submission_info">  
    submitted by <?php echo $image['submitter'];?>
    </div>
    <div id="ratingcontainer">    
    <form id="ratingform">   
    <input name="vote" type="button" onclick="getVote('<?php echo $image['filename'];?>')" value='Like' id="likebutton"/> 
    <input name="dislike" type="button" value='Disike' id="dislikebutton"/> 
    </form>
    
    
    <div id="rate_count">
    <div id="response<?php echo $i; ?>">
    
    <?php echo $image['rating'];?>
    
    </div>
    </div>
    </div>
    </td>
    <td id="front_pg_img" valign="center" align="center">
    <a onClick="switchImageUrl('<?php echo $image['filename']; ?>', '<?php echo $image['width']; ?>', '<?php echo $image['height']; ?>')"><img src="<?php echo $image['filename'];?>" id="front_pg_thumbnail"/></a>
    </td>
    </tr>
    </table>
    
    <?php $i ++; } ?>
    

    Notice the $i = 1 before the foreach as well as the $i ++ before the closing }. Also, echo $i in the response div id.

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

Sidebar

Related Questions

I have a PHP form that is inserting information into a database. It all
I have a database table that stores document information (DocID, Name, Type, Owner, etc).
I have a table generated from some PHP code that lists a SMALL amount
Suppose that I have a database table that contains information on cities across the
I have an ObservableCollection of class Customers that I fill from a database query.
I have an ecommerce MySQL database that stores order information in the table 'orders'
Dear all, I have a select query that currently produces the following results: DoctorName
I have a query that selects rows in a ListView without having a limit.
So I have this query that works perfectly: SELECT users.*, GROUP_CONCAT(categories.category_name) AS categories FROM
I have a query that looks a bit like this: SELECT weekEnd, MAX(timeMonday) FROM

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.