Jump to content

Recommended Posts

I would appreciate any form of help to this problem:

 

I have two tables named doctors and fields with a one to many relationship with the field being the one part and doctors the many part.

 

My form is supposed to insert into the doctors' table and as well select has a select option the chooses from already existing fields in the fields table.

 

The name of my foreign key in the doctors' table is "field_id".

 

How can i this insert in the two tables?

Thanks for your attention. I just realized i dont have to insert into the two tables instead i would just update the foreign key that is in  doctors.

 

But how the form is to be filed is using the field names. I dont know if you can get the picture of what am trying to explain. Thanks once more

<?php include("includes/database.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>NHIS - Doctors' Registration</title>
<link rel="stylesheet" type="text/css" href="styles/reg_doc.css">
</head>


<body>
<div id = "container">

  <div id = "header"><a href="">Back to Home</a></div>

<div id = "title"><h3>DOCTOR'S REGISTRATION FORM</h3></div>


<div id = "content">
<div id = "form_cont">

<form id="form1" name="form1" method="post" action="create_doctor.php">

    <fieldset>
	<fieldset>
    <label for="email"><span>Email Address:</span>
    <input type="text" name="email" id="email"/>
    </label>

    <label for="pass"><span>Password:</span>
    <input type="password" name="pass" id="pass"/>
    </label>

    <label for="pass_conf"><span>Confirm Password:</span>
    <input type="password" name="pass_conf" id="pass_conf"/>
    </label>
	</fieldset>
	<fieldset>
	<label for="Fname"><span>First Name:</span>
    <input type="text" name="Fname" id="Fname"/>
    </label>

	<label for="Lname"><span>Last Name:</span>
    <input type="text" name="Lname" id="Lname"/>
    </label>

	<label for="Sname"><span>Surname:</span>
    <input type="text" name="Sname" id="Sname"/>
    </label>
<?php
    $fields = mysql_query("SELECT * FROM field",$connection);

if(!$fields){ die("Error1: " . mysql_error()); }
	
	?>
	<label for="field"><span>Field:</span>
    <select name="field">
<?php
	while($row = mysql_fetch_array($fields)){
			echo "<option value=\"{$row["field"]}\" > {$row["field"]} </option>"	;
	}
?>
    </select>

    </label>

  </fieldset>
  
  <fieldset class="f1">
  <label for="address"><span>Address:</span>
    <input type="text" name="address" id="address"/>
    </label>

	<label for="dob"><span>DOB:</span>
    <input type="text" name="dob" id="dob"/>
    </label>
  </fieldset>
   
   <fieldset>
	<label for="gender"><span>Gender:</span>
    <input type="radio" name="gender" value = "Male"/> Male <br/ >
	    <input type="radio" name="gender" value = "Female"/> Female
    </label>
   </fieldset>
    
	  </fieldset>
		<div>
		<input id="buttondiv" type="submit" name="submit" value="REGISTER"/>
		</div>
  </form>
</div>

</div>

</body>

</html>

This is the doctors' form. How can i insert into my database?

I have written none yet. The only php is in the html and it pulls up all the fields in the field table to the select option. What I wish to do is to insert this into my database with respect to the selected option.

 

Thanks

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.