I have a project where I need users to be able to save their work, then at a later date select the session/data from their previous work and continue.

I have completed all of the coding (and it works) to save the current session under their userid, and populates a table with their work.

I now want to be able to give the option to retrieve all of the rows in a table and be able to select a row to load. I have previously created a form where i populate a single field into a drop down and select a single column and that works. However, I am struggling with populating a table with results that a user can pick one row.

I have the table returning the results like this:

 echo '<html><Tbody><table  border="1" class="ResultsTbl" id="maintable"><th width="10"> ID </th><th width="5">Session</th><th     width="5">User</th><th width="10">LastMod Time</th><th width="10">Start Time</th><th width="10">EndTime</th><tr>';

while ($i < sqlsrv_num_fields (  $stmt ))
{
    $meta = sqlsrv_field_metadata (  $stmt );
    $i = $i + 1;
}
echo '</tr>';

while ( ($row = sqlsrv_fetch_array( $stmt, SQLSRV_FETCH_ASSOC)  ))
{
    //$formattedDate = date("d-m-Y", strtotime($myrow["date"]));
    $formattedLMDate = date("Y-m-d h:i:sa",strtotime($row['lastmod']));
    $formattedStartDate = date("Y-m-d h:i:sa",strtotime($row['start']));
    $formattedEndDate = date("Y-m-d h:i:sa",strtotime($row['end']));

    echo '<td>'.$row['id'].'</td>'.'<td>'.$row['session'].'</td>'.'<td>'.$row['userid'].'</td>'.'<td>'.$formattedLMDate.'</td>'.'<td>'.$formattedStartDate.'</td>'.'<td>'.$formattedEndDate.'</td>';
        echo '</tr>';
    echo '</tr>';
}

sqlsrv_free_stmt($stmt);
echo '</table></Tbody></html>';

The above code returns a formatted list, but i can't figure out how to make:

  1. The table to have a 'hover' option where the color changes for the row (mouse hover)
  2. add a radio button to each row for a user to select a row.

I know this is not simple, and appreciate assistance. Any pointers/directions would help

Thanks,
Greg

safrinrahman commented: WOW! thats really a great project to solve my problem. +0

1 use bootstrap css or any other you know for row hover
https://www.w3schools.com/bootstrap/bootstrap_tables.asp

2 put your table under < form > tag
Add one more th/td in header and whole loop.
..
.
.
<th width="5">select row</th>
<th width="5">ID</th>
.
.
While..
..
.
.
echo '<td><input type=radio name =selrow value='.$row['id'].' ></td>'.echo '<td>'.$row['id'].'</td>'
...
.
.

commented: Thank-You very much, got me on the right track and I now have a working selectable table/form +0

Thank-You - problem solved.

Wow! thats really a great project for us to solve our problem

Double tap the rundown box, drop-down rundown box, or combo box control that you need to populate. Snap the Data tab. Under List box sections, click Look up values from an outer information source. In the Data Source list, click the information source that you need to utilize.

Thanks for this post

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.