Click here to Skip to main content
15,894,907 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
WHEN I SUBMIT A DATA TO MYSQL DB THEN I WANT TO GENERATE A POPUP MENU SHOW ID NO OF SUBMIT DATA PLEASE GUIDE ME SIR

PHP
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "TB";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
     die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT id FROM COMP";
$result = $conn->query($sql);

if ($result->num_rows > 0) {
     echo "<table><tr><th>ID</th></tr>";
     // output data of each row
     while($row = $result->fetch_assoc()) {
         echo "<tr><td>" . $row["id"]. "</td></tr>";
     }
     echo "</table>";
} else {
     echo "0 results";
}

$conn->close();
?>
Posted
Updated 25-Sep-15 16:39pm
v2
Comments
OriginalGriff 25-Sep-15 14:43pm    
DON'T SHOUT. Using all capitals is considered shouting on the internet, and rude (using all lower case is considered childish). Use proper capitalization if you want to be taken seriously.
Patrice T 25-Sep-15 22:41pm    
Use lowercase too.
It is allowed to use more than a sentence to ask a question.
Kenneth Haugland 26-Sep-15 2:03am    
Nah, to save storage space in my brain I now only learn lower case letters. :laugh:
Patrice T 26-Sep-15 2:16am    
:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900