Radio Button inside of table

Discussion in 'PHP' started by lost, Dec 15, 2005.

  1. #1
    i'm looking to create a table that contains as the first column a radio box, following a row of extracted data from my database.

    Below is the piece of code that will produce my table:

    
    echo '<TABLE BORDER="1" CELLPADDING="4" CELLSPACING="2">';
    echo '<TR><TD>Check</TD><TD>Unit Name</TD><TD>Unit Part No</TD><TD>Description</TD><TD>Part No</TD></TR>';
    extract($rows);
    echo "<TR><TD><INPUT TYPE=radio NAME=\"radio\" VALUE=\"$gid\"/></TD><TD$unitname</TD><TD> $unitpartno</TD><TD$description</TD><TD>$partno</TD></TR>";
    while($rows = @mysql_fetch_array($result))
    {
        extract($rows);
        echo "<TR><TD><INPUT TYPE=radio NAME=\"radio\"    VALUE=/></TD><TD>$unitname</TD><TD>$unitpartno</TD><TD>$description    </TD><TD>$partno</TD></TR>";
    }
    echo '</TABLE>';       
    
    
    PHP:
    Now, what i'm trying to accomplish, is when the user selects a certain radio box, i need to extract the row of data that is associated with that radio box.

    Could someone please give me a hand.
     
    lost, Dec 15, 2005 IP
  2. onlyican.com

    onlyican.com Peon

    Messages:
    206
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Why are you using \" you can use '

    it is cleaner

    example

    echo "<tr><td><input type='radio' NAME='radio'... ";

    also
    when having a var
    use ".$var."
     
    onlyican.com, Dec 26, 2005 IP
  3. BKSH

    BKSH Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hey do the data come from the single database?
    If this is the condition the again retrive the data from the database.
    If you donot want this you can use hidden fields to store the data.
    eg. <input type='hidden' name='unitname<?=$gid?>' value='<?=$unitname?>'>
    Then on the processing page you can get value by
    $val = $_POST['unitname'.$_POST['radio']]

    Have fun.;-)
     
    BKSH, Dec 28, 2005 IP
  4. blissallstar

    blissallstar Peon

    Messages:
    176
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Are you talking about as soon as the radio button is selected or after they hit the sumbit button, because php is server side and they will have to hit that submit button in order to extract right then and there, but if you use some javascript and maybe an iframe it could be done.
     
    blissallstar, Dec 28, 2005 IP