Connecting two tables - row by row association

Tuesday, November 3, 2015

I got two tables in phpmyadmin and I am displaying them in two different php pages.



How can I display the contents of the first table from the page where I am displaying the second table, row by row.



What I want to achive is: each row of the second table have a button that onclick will show (throw a modal-pop-up) the info which are in the first table.



So the button of the row1-table2 will show me only the info of row1-table1 and so on....



I am able to implement the button for each row and the pop-up but I can Only display the info of the entire first table and not of the single row associated.



enter image description here
-------------code update



    




connect_errno > 0) {
die('Unable to connect to database [' . $link->connect_error . ']');
}
if (isset($_POST['update'])) {
$results = $link>query("UPDATE job SET status='$_POST[status]', priority='$_POST[priority]' WHERE id='$_POST[hidden]'");
$results = $link>query("UPDATE **table2** SET status='$_POST[status]' WHERE id='$_POST[hidden]'");}

$sql = "SELECT * from job";
if (!$result = $link->query($sql)) {
die('There was an error running the query [' . $link->error . ']');
}
echo "…………./* Get field information for all columns */………… "

while ($row = $result->fetch_assoc()) {
echo "";

echo "

" . $row['id'] . "
" . $row['device'] . "
" . $row['model'] . "
" . $row['problem'] . "


" . $row['status'] . "
New
Progress
Wait
Done
Close


" . $row['priority'] . "
High
Medium
Low


" . $row['status'] . "
" . $row['priority'] . "

** Update**

** Info**
"; echo "";}echo "

";

?>

!-- Trigger the modal with a button -->


<!-- Button trigger modal -->

0 comments:

Post a Comment