Как отправить данные из динамической таблицы php внутри тега привязки на другую страницу (description_of_gpu.php), а также как получить эти данные на новой странице.
Япопытка отправить переменную, сгенерированную внутри тега table-data, на другую страницу, которая сама по себе извлекается из базы данных «MySQL». Как только я получу эти данные, я буду искать в своей базе данных с той же «NameOfVcard» и отображать ее описание.
Код внутри «gpu_table_page.php»
<?php
$conn = mysqli_Connect('localhost', 'root', '', 'gpu_db');
//$result = mysqli_query($conn,"select * from gpu_table");
?>
<!DOCTYPE html>
<html>
<head>
<title>gpu page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="css/style_of_gpu.css" type="text/css">
<script type="text/javascript" src="javascript/javascript_of_gpu.js"></script>
</head>
<body>
<br />
<br/>
<div style="margin-left: 150px; margin-right: 20px; vertical-align: right">
<table style="margin-top: 40px" border="3px">
<thead>
<tr>
<th>SrNo</th>
<th>Video card Name</th>
<th>Architecture</th>
<th>Boost_clock</th>
<th>Core_speed</th>
<th>Memory</th>
<th>Manufacturer</th>
</tr>
</thead>
<tbody>
<?php
$data = 1000;
$sql = "SELECT * FROM gpu_table WHERE Core_Speed<? ORDER BY Core_Speed DESC;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
echo "SQL statement failed";
}
else{
mysqli_stmt_bind_param($stmt,"i",$data);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$k = 1;
while ($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>".$k."</td>";
echo "<td><a href="description_of_gpu.php?NameOfVcard=.$row['Name'].">".$row['Name']."</a></td>";;
echo "<td>".$row['Architecture']."</td>";
echo "<td>".$row['Boost_Clock']."</td>";
echo "<td>".$row['Core_Speed']."</td>";
echo "<td>".$row['Memory']."</td>";
echo "<td>".$row['Manufacturer']."</td>";
echo "</tr>";
$k = $k + 1;
}//while end
}//else end
?>
</tbody>
</table>
</div>
<br />
</body>
</html>
Код внутри »description_of_gpu. php "
<?php
$conn = mysqli_Connect('localhost', 'root', '', 'gpu_db');
//$result = mysqli_query($conn,"select * from gpu_table");
?>
<!DOCTYPE html>
<html>
<head>
<title>gpu page</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js"></script>
<link rel="stylesheet" href="css/style_of_gpu.css" type="text/css">
<script type="text/javascript" src="javascript/javascript_of_gpu.js"></script>
</head>
<body>
<br />
<br/>
<?php
//the below "$data" variable will contain the "NameOfVcard" data.
$data = "GeForce GTX 1080 Ti Zotac Founders Edition 11GB";//currently "$data" is a static variable
$sql = "SELECT * FROM gpu_table WHERE Name=?;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)){
echo "SQL statement failed";
}
else{
mysqli_stmt_bind_param($stmt,"s",$data);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$k = 1;
while ($row = mysqli_fetch_array($result))
{
echo "<p>";
echo "<em>".$row['Name']."</em>"." is from the architecture "."<b>".$row['Architecture']."</b>"."where Boost_Clock is "."<b>".$row['Boost_Clock']."</b>"."Mhz and Core_Speed is ".$row['Core_Speed']."Mhz having ".$row['Memory']."mb of DRAM which is of the type ".$row['Memory_Type']." and have ".$row['DVI_Connection']." DVI connections";
echo "<br>";
echo "also having ".$row['HDMI_Connection']." HDMI ports which is Manufactured by ".$row['Manufacturer']." consuming ".$row['Max_Power']." power and it has ".$row['Power_Connector']." power connectors ";
echo "</p>";
$k = $k + 1;
}//while end
}//else end
?>
</div>
<br />
</body>
</html>