Reputation: 169
I'm trying to link one php file to another one. The first file, which is a query result of one mysql command, contains introduction of all the products.
When the "Details" button is clicked, I want the page to be redirected to another php file, which accepts the query result (ID, name) from the first file and output the detailed information.
Now I'm stuck at the "button" step. Could anyone help me to link the two files?
<div><button href = "Product_details.php" type="submit" name="Details" class="btn btn-default">Details</button></div>
Upvotes: 0
Views: 2377
Reputation: 3724
you can use the $_GET variable like :
<div><button href = "Product_details.php?data1=value2&data2=value2" type="submit" name="Details" class="btn btn-default">Details</button></div>
value1 and value2 are supposed as two variables available in the current php file which the button exist named $data1 and $data2
it's goning to be something like :
<div><button href = "Product_details.php?data1=<?php echo $data1?>&data2=<?echo $data2?>" type="submit" name="Details" class="btn btn-default">Details</button></div>
and in the Product_details.php , you can get you data as :
$data1 = $_GET['data1'];
$data2 = $_GET['data2'];
Upvotes: 5