Hi webdevelopers,

I am trying to INSERT INTO a table, a RETRIEVED gender SELECT FROM another table, but it misses a piece of code, to function:

$page_title = 'Register';
include ('./header2.html'); 

// Connect to the database.
require_once ('./Script14.1_mysql_connect.php');
if (isset($_POST['submitted'])) {

if  (!empty($_POST['types']) && ($_POST['types_id']) > 1) {
$g = (int) $_POST['gender'];
} else {
$g = FALSE;
echo '<br ><font color="white" size="-1">Please choose your gender!</font>';
}
} 

if ($g) {
$query = "INSERT INTO ..... (gender) VALUES ('$g' )";
        if ($result = mysqli_query ($dbc, $query)) {//or trigg_error.....

?>
<!--right part start -->
					<div id="right">
						<h3 ><em>Become a member</em><br />
						Join now! </h3>
						<p class="text Estilo8"> Fields with asterisks are obligatory* !
						<br />Password: use only letters and numbers. It must be between 4 and 20 characters long.</p>
						<br />
												
						<form method="post" action="register1.php">
												
<p><font color="pink" > <label>Gender: *</label>
<select name="gender"> <option> Select One</option>
<?php 
$query = "SELECT gender FROM types ";
$result = mysqli_query ($dbc, $query);
while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) {
echo "<option value=\"{$row ['types_id']}\">{$row['gender']}</option>\n";
}
mysqli_close($dbc);

include ("./footer.html");

</select></p>   

?>

Does someone knows what is missing, please?

Many thanks!

Masks.be

in this piece of code

$query = "SELECT types_id,gender FROM types ";
$result = mysqli_query ($dbc, $query);
while ($row = mysqli_fetch_array ($result, MYSQLI_ASSOC)) {
echo "<option value=\"{$row ['types_id']}\">{$row['gender']}</option>\n";

try to retrieve types_id in select query.

Hi replies,

It is difficult to see your name.

Thanks but it is not that, the code says

SELECT gender FROM types "

.

It seems it is missing a <form> around the $query; but there is already another <form> involving.

Masks.be

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.