Created
February 23, 2024 08:14
-
-
Save overnew/9a045f8cc015d6ea0d9de0b44a9a4934 to your computer and use it in GitHub Desktop.
example-mysql-apache.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$db = new mysqli('db', 'root', 'wordpress', 'team1'); | |
if($db->connect_error){ | |
die('Not Connected : ' . $db->connect_error); | |
} | |
//team list 출력 | |
{ | |
echo '<p>' . "team1" . '</p>'; | |
echo "-------------------------------------------------------"; | |
$conn=mysqli_connect('db', 'root', 'wordpress', 'team1'); | |
$sql="select * from user"; | |
$result=mysqli_query($conn, $sql); | |
while( $row = mysqli_fetch_array( $result ) ) { | |
echo '<p>' ."id : ". $row[ 'ID' ] . "  " . "NAME : ". $row[ 'NAME' ] . '</p>'; | |
} | |
echo "-------------------------------------------------------"; | |
} | |
if ($_SERVER["REQUEST_METHOD"] == "POST"){ | |
$db = new mysqli('db', 'root', 'wordpress', 'team1'); | |
if($db->connect_error){ | |
die('Not Connected : ' . $db->connect_error); | |
} | |
$sql2 = "select ID from user where ID='$_POST[ID]'"; | |
$result2 = $db->query($sql2); | |
if($result2->num_rows !== 0){ | |
$conn=mysqli_connect('db', 'root', 'wordpress', 'team1'); | |
$sql="select * from user where ID='$_POST[ID]'"; | |
$result=mysqli_query($conn, $sql); | |
while( $row = mysqli_fetch_array( $result ) ) { | |
echo '<p>' ."id : ". $row[ 'ID' ] . "  " ."NAME : ". $row[ 'NAME' ] . "  " . "AGE : ". $row[ 'AGE' ] . "  " . "GOAL : ". $row[ 'GOAL' ] . "  " . "SKILL : ". $row[ 'SKILL' ] . '</p>'; | |
} | |
}else{ | |
echo "not in my team! "; | |
} | |
} | |
?> | |
<html> | |
<h1> Select A Member! </h1> | |
<form action="" method="post"> | |
<label for="ID">member id : </label> | |
<input type="text" name="ID"> | |
<input type="submit" value="submit"> | |
</form> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment