Skip to content

Commit a03a29d

Browse files
authored
Added ".php" source file.
1 parent d04a9a1 commit a03a29d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

PHP_MySQLI_DropDown_Menu_ENUM.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
$HTMLPage= <<<HTML
4+
**//INSERT HERE THE HTML CODE YOU ONLY WANT TO SHOW IF THE DROPDOWN MENU HAS BEEN CORRECTLY INSERTED:**
5+
<input type="submit" name="submit" value="Submit Form."/>
6+
<input type="reset" value="Reset Form" />
7+
8+
HTML;
9+
10+
if($myDBObject = new mysqli("**SERVER_HOSTNAME**","**MySQL_USERNAME**","**MySQL_PASSWORD**")){
11+
12+
$myDBObject->select_db("DB_NAME");
13+
14+
if(!$queryResult = $myDBObject->query("SHOW COLUMNS FROM **tableName** WHERE Field=\"**columnName**\"")){
15+
echo "<h2>There was an error while creating the page.</h2>";
16+
}else{
17+
if($queryResult->num_rows == 0){
18+
echo "<h2>Check the table definition.";
19+
}else{
20+
echo"<hr><br><h2>**Title**:</h2>";
21+
$enumString = $queryResult->fetch_array()['Type'];
22+
$enumString = substr($enumString,6,strlen($enumString)-8);
23+
24+
$enumString = str_replace('\'','',$enumString);
25+
$arrayEnumOptions = explode(',',$enumString);
26+
echo "<select name=\"**select_input_name**\" required>";
27+
foreach($arrayEnumOptions as $singleOption){
28+
echo "<option value=\"$singleOption\">$singleOption</option>";
29+
}
30+
echo "</select>";
31+
echo $HTMLPage;
32+
}
33+
}
34+
35+
}else{
36+
echo "<h2>There was an error while creating the page.</h2>";
37+
}
38+
?>

0 commit comments

Comments
 (0)