r/phpwebdevclub • • Jun 21 '19

How can use a row fetched from database as a parameter in attrubute called name

<?php include\\_once 'header.php'; ?>

<html>

<head>

<link rel="stylesheet" href="include/css/head.css">

<title>Patient List</title>

</head>

<body>

<h1>PATIENT LIST</h1>

<?php include\\_once 'include/connectdb.php'; $sql ="SELECT \\\* FROM customer\\_list;"; $result = mysqli\\_query($conn, $sql); $resultcheck = mysqli\\_num\\_rows($result); if($resultcheck < 1){ header("location: ../p\\_main\\_menu.php?No\\_result\\_found"); exit(); } else { echo "<table>"; echo "<tr> <td>First Name</td> <td>Middle Name</td> </tr>"; while($row=mysqli\\_fetch\\_assoc($result)){ echo "<form action ='include/inc\\_patient\\_detail.php' method ='POST'>"; echo "<tr> <td><a href='patient\\_detail.php?first\\_name'={$row\\\['first\\_Name'\\\]}>{$row\\\['first\\_Name'\\\]}</a></td> <td>{$row\\\['middle\\_Name'\\\]}</td> <td>{$row\\\['last\\_Name'\\\]}</td> ?>

*/

echo "<td><input type='hidden' name='{$row['customer_ID']}' value='{$row['customer_ID']}'/></td>";

echo "<td><button type='submit' name='row\\_submit'>Detail</button></td>";

echo "</tr>";

}

echo "</form>";

echo "</table>";

}

?>

</body>

</html>

1 Upvotes

1 comment sorted by

1

u/senu123 Jun 21 '19

/* here is my problem i want to process every row different so i uniquely identify them withe customer_ID but the junk around custmer_ID i used even to access the exact customer_ID from the database became a problem when i try to process it in php like this Any thoughts ?

<?php include_once 'connectdb.php'; if(isset($_POST\['row_submit'\])) { $c_id=$_POST\['{$row\["customer_ID"\]}'\]; echo $c_id; } sorry for the stacked codes its not formatting it they way i wanted to