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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T11:48:07+00:00 2026-06-18T11:48:07+00:00

I have a standard Mysqli/php code that echo a list of items. So lets

  • 0

I have a standard Mysqli/php code that echo a list of items.

So lets say that a user has chosen to edit a specified product. The products is being
printet in a while loop. How do i switch content in only ex. product 9 if there is printed 100 products in a while loop?

All the products is in a Div.

Some code ex:

$query = $mysqli->query("SELECT item_name, item_id FROM items");
while($items = $query->fetch_assoc()){

  echo $items['item_name'];
  echo '<a href="" onclick="switch content of only the single product that has been chosen">Edit me</a>'

}
  • 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-18T11:48:08+00:00Added an answer on June 18, 2026 at 11:48 am

    You can use a ternary operator for this:

    $query = $mysqli->query("SELECT item_name, item_id FROM items");
    while($items = $query->fetch_assoc())
    {   
        $clickEvent = ($items['item_id'] == 9) ? 'for id 9' : 'for others';
        echo $items['item_name'];
        echo '<a href="" onclick="'.$clickEvent.'">Edit me</a>'
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a standard list view setup with backbone that looks something like below.
I have a standard text input that has a blur event. The blur event
I have a PHP application that has grown in size. The database used to
I have the following quite simple test PHP code that extracts the data and
I have standard source code package under Linux which requires to run ./configure make
I have a standard code like below to validate xml against xsd, but it
I have a standard form array in PHP like this. I need to account
I have a problem with producing a Register using my MySQLI Code. The tables/connection
Here is the standard code I am using for getting cart items and their
I have an existing, non-framework-based PHP/MySQL website. It has a simple security model, with

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.