How to create a new page from a clickable row table

Codes here !

Moderators: egami, macek, gesf

Post Reply
New php-forum User
New php-forum User
Posts: 1
Joined: Sun Mar 12, 2017 9:47 am

Sun Mar 12, 2017 9:50 am

I have a problem and i can't find any solution on the internet. So i have a db with about 20 columns. I print from this db only 5 columns for a preview like this:

Code: Select all

$host    = "localhost";
$user    = "user";
$pass    = "";
$db_name = "db_test";

//create connection
$connection = mysqli_connect($host, $user, $pass, $db_name);

//test if connection failed
    die("connection failed: "
        . mysqli_connect_error()
        . " (" . mysqli_connect_errno()
        . ")");

//get results from database
$result = mysqli_query($connection,"SELECT id,first,sec,school,data FROM test");
$all_property = array();  //declare an array for saving property

//showing property
echo '<table class="data-table" border ="1">
        <tr class="data-heading">';  //initialize table tag
while ($property = mysqli_fetch_field($result)) {
    echo '<td>' . $property->name . '</td>';  //get field name for header
    array_push($all_property, $property->name);  //save those to array
echo '</tr>'; //end tr tag

//showing all data
while ($row = mysqli_fetch_array($result)) {
    echo "<tr>";
    foreach ($all_property as $item) {
        echo '<td>' . $row[$item] . '</td>'; //get items using property value
    echo '</tr>';
echo "</table>";
After the table is print, I want when click is press to create a new page with all the records from the db for that specific id. I have search over the internet but i can't find any solution. Can anyone help me ?:) Thanks in advice.

php-forum Fan User
php-forum Fan User
Posts: 564
Joined: Fri Apr 01, 2016 2:18 am

Mon Mar 13, 2017 10:57 pm


Code: Select all


Code: Select all

$pdo = new PDO(...);
$stmt = $pdo->prepare('select x, y, z from foo where bar = ?');

Post Reply