I want to create network graph with checkboxes. If I click a data's button, it shows where this data is connected to. If I select 1 or more, I want to print the original data node (it's working), and the selected nodes. My idea is to post the checkbox, the button and the td to that PHP file where I encode it to JSON, but it's not working. Now if I click the button, the modal disappear.
How can I post the checkbox and the td values to another PHP file to encode it to JSON?
Checkbox
$output .='<form name="relationCheck" action="nodes.php" method="post">';
while($row=$result->fetch_assoc()){
$output .='
<tr>
<td align="center"><input name="id[]" class="checkboxes" type="checkbox" value="'.$row["id2"].'"</td>
<td>'.$row["data"].'</td>
</tr>
';
while($row = $result3->fetch_assoc()){
$output .= '<input type="button" name="submit" id="'.$row["data_id"].'" value="view" class="btn btn-success relations">';
}
$output .= '</form>';
nodes.php
$id2=$_POST['id'];
if(isset($id2)){
$sql2=$conn->prepare("SELECT id, data
FROM table1
WHERE id=?
GROUP BY id");
$sql2 -> bind_param('i', $id2);
$sql2 -> execute();
$result2 = $sql2 -> get_result();
$sql2 -> close();
while($row = mysqli_fetch_assoc($result2)){
$id2 = $row['id'];
$data = $row['data'];
$arr[] = array("id" => $id2,
"label" => $data);
}
echo json_encode($arr);
Aucun commentaire:
Enregistrer un commentaire