Hello, I have a simple HTML table generated using Mysql and PHP:

type    region  platform    price $/h
m3.xlarge   ap-northeast-1  windows 0.980
hs1.8xlarge ap-northeast-1  rhel    5.810
hi1.4xlarge ap-northeast-1  rhel    3.960
m1.medium   ap-northeast-1  windows 0.230
cg1.4xlarge ap-northeast-1  rhel    4.450
cc2.8xlarge ap-northeast-1  rhel    3.100
c1.xlarge   ap-northeast-1  rhel    0.855
c1.medium   ap-northeast-1  rhel    0.254
m2.4xlarge  ap-northeast-1  rhel    2.135
m2.2xlarge  ap-northeast-1  rhel    1.079

I would like to choose one row of my table, and send two or more contents throught GET or POST to another page, using the easy way as possible.

Today, I can send only one parameter using "radio" button like this:

<form method="GET" action="table.php">
<table>
<?php
$query="SELECT * from prices ORDER BY region limit 10";
$result=mysql_query($query,$connection);
while ($linha = mysql_fetch_array($result)) {
?>
<tbody>
    <tr>
     <td><input type="radio" name="region"  value="<?php echo $linha['region'] ?>" /></td>
     <td><?php echo $row['type']; ?></td>
     <td><?php echo $row['region']; ?></td>
     <td><?php echo $row['platform']; ?></td>  
     <td><?php echo $row['price']; ?></td>                                      
    </tr>
</tbody>

<?php
}
?>

</table>
<input type="submit" value="Submit"/>       
</form>

So, if I click in "Submit" button I got:

table.php?region=ap-northeast-1

How can I get, for example:

tabela.php?region=ap-northeast-1&type=c1.medium

PS: I would like to be able to sent the values "type" AND "region" to another page :)

Thanks a lot

Dani AI

Generated

Three practical ways to submit two (or more) columns when a single row is selected — ordered from safest/best-practice to quickest:

  1. Send the row’s primary key and fetch the full row on the target page (recommended). This keeps form data minimal, avoids URL length/encoding problems, and makes server-side validation simple. Example form input generation and server retrieval using PDO:
<!-- row selector -->
<input type="radio" name="row_id" value="<?php echo (int)$r['id']; ?>">

// on target page
$id = (int)($_POST['row_id'] ?? 0);
$stmt = $pdo->prepare('SELECT type, region, platform, price FROM prices WHERE id = ?');
$stmt->execute([$id]);
$row = $stmt->fetch(PDO::FETCH_ASSOC);
  1. Pack multiple fields into the radio value and parse server-side (quick hack). Encode to avoid delimiter problems:
// generator (encode)
$value = rawurlencode(base64_encode(json_encode(['type'=>$r['type'],'region'=>$r['region']])));
echo '<input type="radio" name="sel" value="'.$value.'">';

// receiver (decode)
$data = json_decode(base64_decode(rawurldecode($_REQUEST['sel'])), true);
$type   = $data['type'];
$region = $data['region'];
  1. Use a tiny bit of JavaScript to copy the chosen row’s visible cells into hidden inputs just before submit. That keeps HTML readable and submits named fields directly (useful when avoiding an extra DB hit).

Notes and cautions:

  • Prefer POST for anything non-public. Always validate and escape server-side; never trust client-submitted values.
  • Avoid deprecated mysql_* functions — use PDO or mysqli with prepared statements.
  • As noted, seeing the actual table.php loop and the field names (how rows are identified) will clarify which approach fits best for .

can you post your table.php code ?

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.