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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:05:55+00:00 2026-05-17T01:05:55+00:00

I create a table using PHP from a database, meaning the size of the

  • 0

I create a table using PHP from a database, meaning the size of the table and values vary.

The table creation:

<table>     
            <thead>
                <tr>
                    <th>Ticket</th>
                    <th>Empresa</th>
                    <th>Requerente</th>
                    <th>Motivo</th>
                    <th>Data</th>
                    <th>Hora</th>
                </tr>
            </thead>

        <tbody>
            <form name="goTicket" action="resolver.php" method="POST" >         
<?php   
    $sql = "QUERY";
    $result = mysql_query($sql);
    while ($row = mysql_fetch_array($result)) {
        echo "<tr onmouseover=\"this.style.background='#EFF5FB';this.style.cursor='pointer'\"
        onmouseout=\"this.style.background='white';\" onclick=\"javascript: submitform()\">";
        echo "<td>$row[Ticket]</td>";
        echo "<input type='hidden' name='_ticket' value='$row[Ticket]' />";
        echo "<td>$row[Empresa]</td>";
        echo "<td>$row[Requerente]</td>";
        echo "<td>$row[Motivo]</td>";
        echo "<td>$row[Data]</td>";
        echo "<td>$row[Hora]</td>";
        echo "</tr>";
    }
    echo "</form>";
    echo "<tr><td colspan='6' style='text-align: center;'><form action='adminmenu.php' ><br /><input type='submit' name='woot' value='Main Menu' /></form></td></tr>";  
    echo "<tbody>";
    echo "</table>";
?>

The Javacript function used to submit is this one:

<script type="text/javascript">
        function submitform()
        {
            document.forms["goTicket"].submit();          
        }
</script>

Now whenever I click on a row it takes to the appropriate page “resolver.php” but always sends the most recent data, from last time the while was executed.

I need the value from the first cell, or the hidden input tag, that contains what I need, from the row I click.

Thank you.

  • 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-17T01:05:55+00:00Added an answer on May 17, 2026 at 1:05 am

    Full suggestion

     <script type="text/javascript">
     function submitform(ticket) {
       document.goTicket.elements["_ticket"].value=ticket;
       document.goTicket.submit();
     }
     </script>
     <table>     
            <thead>
                <tr>
                    <th>Ticket</th>
                    <th>Empresa</th>
                    <th>Requerente</th>
                    <th>Motivo</th>
                    <th>Data</th>
                    <th>Hora</th>
                </tr>
            </thead>
    
        <tbody>
    <form name="goTicket" action="resolver.php" method="POST" >
    <input type="hidden" name="_ticket" value="" />
    
    <?php   
        $sql = "QUERY";
        $result = mysql_query($sql);
        while ($row = mysql_fetch_array($result)) {
    ?>    
    
        <tr onmouseover="this.style.background='#EFF5FB';this.style.cursor='pointer'"
        onmouseout="this.style.background='white';" 
        onclick="submitform('<?php echo $row[Ticket]; ?>')">
        <td><?php echo $row[Ticket];     ?></td>
        <td><?php echo $row[Empresa];    ?></td>
        <td><?php echo $row[Requerente]; ?></td>
        <td><?php echo $row[Motivo];     ?></td>
        <td><?php echo $row[Data];       ?></td>
        <td><?php echo $row[Hora];       ?></td>
        </tr>
    <?php } ?>
    
    </form><!-- not really nice -->
       <tr><td colspan="6" style="text-align: center;"><form action="adminmenu.php" >
       <br /><input type="submit" name="woot" value="Main Menu" /></form></td></tr>
        </tbody>
       </table>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create a table in MySql using php. My code looks
Setup: Contact database using 4 tables Contacts Cities States Zips Structure: CREATE TABLE `contacts`
I want to export data and structure from MySQL database using PHP. I know
I want to get the last created table name from a MySQL database using
I'm currently using a script from http://davidwalsh.name/backup-mysql-database-php to do a hotcopy like backup of
I am using php/mysql, and have a database table with image url. I would
I randomly get a row from a mysql-database using php (ugly random, I know).
I am using PHP 5 to create a query page for a MySQL database
I create table using sql developer create table tablenodes ( nodeNo int , nodeName
I have created one table using the below command: create table Table1( Id int

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.