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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:55:37+00:00 2026-06-17T23:55:37+00:00

i m use php which print my table in which first column is sr.no

  • 0

i m use php which print my table in which first column is sr.no but in which i want to store value of exam_id.
how can i get this Exam_id value by javascript

        foreach ($data as $key) {
            echo "<tr>";
            print'
<td class="contact" id="exam_id" name=' . $key['exam_id'] ." width="5%" value='.$key['date'].'>' . $i . '</td>
<td class="contact"  width="20%">' . $key['date'] . '/' . $key['month'] . '/' . $key['year'] . '</td>
<td class="contact"  width="30%">' . $key['Title'] . '</td>
<td class="contact"  width="20%">' . $key['Branch'] . '</td>
<td class="contact"  width="6%">' . $key['Sem'] . '</td>
<td class="contact" width="24%" ><a onclick="javascript:create_result();" href="#">Create Result</a></td>';

            $i++;
            echo "</tr>";
        }

javacript is

<script type="text/javascript">
    function create_result() {

 var exam_id = document.getElementById('exam_id').value



      $.ajax({type:'POST', url: 'result/create_result',data:exam_id, success: function(response) {
              $('#content').html(response);
   }});
    return false;
}
</script>
  • 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-17T23:55:38+00:00Added an answer on June 17, 2026 at 11:55 pm

    Firstly you need to clean up your PHP code. The syntax is a bit off, and is very hard to read.

    Once you have managed to get the PHP to output the HTML correctly you need to change to JavaScript you are using to get the exam_id value.

    As @MarcB said, you have duplicate IDs in your HTML, since you will be running the PHP snippet multiple times as it is a foreach loop. That will result in you having many cells with the id exam_id.

    You need to be able to reference a specific cell in order to get the value of exam_id. Since the id of the cell in question is not unique, it should be converted to a class. <td class="contact exam_id" name... </td>

    Then you need to find a way to uniquely identify each row. This could be done by attaching the exam_id of each row into the row (tr) declaration like so, "<tr id='exam-" . $key['exam_id'] . "' >"; (This would replace line 2 of your PHP)

    Now you have to find a way of identifying which row you wish to have as your context before you can select the value.

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

Sidebar

Related Questions

i'm a beginner to php. i need to use php function which process some
I'm having trouble with grep.. Which four patterns should I use with PHP's preg_grep
I use JEditable for making edit field which following code: $(function() { $(.field).editable(http://localhost/index.php/welcome/update_record, {
Use PHP and Mysql. Fields in my table (product) are id , full_price ,
I use php to display a table of data drawn from my mysql database.
I need to do use php/regex to replace this: {{image-4-m}} to this: <img src=4.jpg
I can't use PHP in my HTML pages. For example, index.html . I've tried
I have a generated table which i need when press button on 6th column
I am taking my first steps into php and I have come across this
I am fetching some data from MySQL which I print into a table. I

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.