Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2004
    Posts
    28

    Unanswered: passing a value of radio button that is determined by DB to a 2nd php page

    I am having trouble passing the value of a radio button that is being determined based on the id value in the database to another php page. Basically the script on update.php succesfully goes through my table and lists every entry with a radio next to that row, this radio button value is the same value as its id in the database.

    I want a user to be able to highlight a record to be edited and then click an update button to where it sends to the input_update.php page and all of the information from that record is already put into the form. I know how to do that but for some reason I can't seem to pass along the value of the selected radio button to the next page.

    here is the code for update.php

    <?
    include ("connect.php");
    ?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>

    <?
    $sql="select ges_id, name, recruiter, salesman, client, position, candidate, salary, fee, stage, total_weighted_gm, this_month_won, first_int, second_int, third_int, proj_close_date, todays_date, notes, current_month from ges, dept where dept.dept_id=ges.dept_id";
    $result=mysql_query($sql);

    $count=mysql_num_rows($result);
    ?>

    <table border="0">
    <tr>
    <td><form name="frm_update_select" method="post" action="input_update.php">
    <table border="1">
    <tr>
    <td align="center" bgcolor="#FFFFFF">#</td>
    <td align="center" bgcolor="#FFFFFF"><strong>Group</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Recruiter</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Salesman</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Client</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Position</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Candidate</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Salary</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Fee</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Stage</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Total Weighted GM</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>This Month GM</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>First Interview</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Second Interview</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Third Interview</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Project Close Date</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Today's Date</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Note</strong></td>
    <td align="center" bgcolor="#FFFFFF"><strong>Current Month</strong></td>
    </tr>
    <?php
    while($rows=mysql_fetch_array($result)){
    ?>
    <tr>
    <td align="center" bgcolor="#FFFFFF"><input name="radio[]" type="radio" id="radio[]" value="<? echo $rows['ges_id']; ?>"></td>
    <td bgcolor="#FFFFFF"><? echo $rows['name']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['recruiter']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['salesman']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['client']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['position']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['candidate']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['salary']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['fee']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['stage']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['total_weighted_gm']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['this_month_won']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['first_int']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['second_int']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['third_int']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['proj_close_date']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['todays_date']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['notes']; ?></td>
    <td bgcolor="#FFFFFF"><? echo $rows['current_month']; ?></td>
    </tr>
    <?php
    }
    ?>
    <tr>
    <td colspan="19" align="center" bgcolor="#FFFFFF"><input name="update" type="submit" id="update" value="Update" onClick="return confirmSubmit()"></td>
    </tr>
    <?
    mysql_close();
    ?>
    </table>
    </form>
    </td>
    </tr>
    </table>
    </body>
    </html>
    no matter what i do i cant seem to pass the value $rows['ges_id'] to the next page.

    I know it passes because i changed to the "get" action and the correct ID number is showing in the url depending on what record i selected, but i can't seem to figure how to utilize that ID.

  2. #2
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    try:

    <input name="radio" type="radio" id="radio" value="<? echo $rows['ges_id']; ?>">

    then on the other page

    $_POST['radio']

    should equal what you want.

  3. #3
    Join Date
    Nov 2004
    Posts
    28
    thanks so much. I had that but it didnt work when the name of the radio button was radio[]..i renamed it just radio and now it works. Thanks so much for the help!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •