Help making a radio button hidden for non-admins

I am trying to hide a radio button based on wether or not a user is an admin

<?php
     if (($_SESSION['admin']) == 0) ?> 
    <script>document.getElementById('adminbutton').style.display = 'none' </script>
    <?php
 if (($_SESSION['admin']) == 1) ?> 
    <script>document.getElementById('adminbutton').style.display = 'block' </script>

Obviously the above doesn't work.. Any help is, as usual, greatly appreciated.
Thanks

How to create a selectable list from sql results

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

Set a variable on a submit

I have a fillin form , which has a submit button. In order to get to the fillin form, the user has already been authenticated and a session has been created, and variables have been added to the session.

In order to process the information, I have another 'insUpSel.php' file which does two things:

  1. populates a MSSQL database via a stored procedure with the contents of the session
  2. retrieves the results from the MS SQL table and populates an HTML table with multiuple result rows.

I want to prevent users from running the 'insUpSel.php' form manually and if they do force users back to the login page.

Is there a way, where I can update a variable before the processing the fillin form data?

ie. $submitted = true   (on fillin form)
then on the insupsel.php 
i check if $submitted = true
- IF TRUE, I set it back to false and continue processing the data
- IF FALSE, i force the user back to the login page

Many thanks

Greg C – New to PHP

I live and work in beautiful BC Canada.

I am a DBA, Data & Application analyst who is new to developing in PHP. I look forward to learning much from this community while on my current project and eventually contributing.

get selection into POST

New to this forum and to programming in PHP, so apologies if I miss some detail.

I have found some code which does almost everything I need, but I can't figure out how to get the 'selected item' from the results on an secondary page (reading in post) ..

this properly retrieves a list of names from a sql table and populates a select list, and two input boxes

<div id="ifNew" style="display:none" >
            <form name = "form2" action="../Form/modified.php" method = "post" enctype = "multipart/form-data">     
            <div class = "form_data1">    

                     <?php

                     $stmt = sqlsrv_query( $conn,$tsql );
                     if( $stmt === false) {    die( print_r( sqlsrv_errors(), true) );}
                            echo "<select id=''nm'' name=''Name''>";
                                while ($row = sqlsrv_fetch_array($stmt, SQLSRV_FETCH_ASSOC)) 
                                    {       echo "<option value='" . $row['Name']. "'>" . $row['Name'] . "</option>"; 
                                    }
                                    echo "</select>"; 


                    sqlsrv_free_stmt($stmt);?>  

                     <input type = "text" name = "group" value = "" size = "30" required/><label> :Group</label> <br>
                     <input type = "text" name = "btype" value = "" size = "30" required/><label> :Type</label><br>
                     <input type = "submit" />
            </form>
                </div>              
            </div>  
        </div>

        What I am struggling with is how to retrieve the selected item from the name list and populate a variable

        modified.php
        <?php
$group = $_POST['group'];
$btype = $_POST['btype'];
$name = $_POST['name'];
?>

while the first two are popuated (group and btype), the name is not, and i receive an error
Notice: Undefined index: name in C:\inetpub\wwwroot\testWeb\Form\modified.php on line 4

please help