Hi
Okay, so I'm following some tutorials and trying to make a rudimentary dating site using PHP and MySQL to get the hang of this stuff.
STAGE ONE
So I kinda thought it out on paper and came up with the following database structure:
Okay, so that covers the database.. I then created that and have that all set-up and ready.PHP Code:Members(memberID, mForname, mSName, mEmail, mGender, mDOB, mHasChildren, mSmokes, mDrinks, mAboutYourself, mAboutFamily, mJoinDate, mUsername, mPassword)
Lookup(relMemberID, relReligionID, relRelationID, relMStatusID, relHeightID, relBuildID, relComplexionID, relCBirthID, relCOriginID, relEducationID, relOccupationID, relDietID)
Religion(religionID, religionName)
Country(countryID, countryName)
Occupation(occupationID, occupationName)
Height(heightID, heightValue)
Build(buildID, buildType)
Age(ageID, ageValue)
MStatus(mMStatusID, mMStatusType)
Education(educationID, educationType)
Relation(relationID, relationType)
Complexion(complexionID, complexionType)
Diet(dietID, dietType)
STAGE TWO
Now, I'd thought I'd give it a go at writing a joining script.
Firstly, I read somwhere that it was a good idea to seperate the database connection stuff, so I do that and 'import' the configuration file 'conf.php' and then I do the database connection stuff:
Then I thought I should create a record, so I did this as follows:PHP Code:<?php if (isset($_POST['submit'])) { // a new member joins using the form below
include("conf.php" ); // include the configuration file
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect to database!" );
// select database
mysql_select_db($db) or die ("Unable to select database!" );
Then, I thought I'd pre-set all my SQL for the drop-down boxers etc:PHP Code:// generate and execute query
$query = "INSERT INTO Members SET " .
"mForename = $_POST['Forename'], " . // forename
"mSName = $_POST['Surname'], " . // surname
"mEmail = $_POST['EMail'], " . // e-mail
"mGender = $_POST['gender'], " . // gender
"mDOB = $_POST['mDOB'], ". // date of birth
"mHasChildren = $_POST['haschildren'], " . // do they have children?
"mSmokes = $_POST['smoking'], " . // do u smoke?
"mDrinks = $_POST['drinking'], " . // do u drink?
"mAboutYourself= $_POST['aboutyourself'], " . // more about yourself
"mAboutFamily = $_POST['aboutfamily'], " . // more about your family
"mJoinDate = $_POST['DATE'], " . // date of registration
"mHeardFrom = $_POST['Heardfrom'], " . // how did u hear about us?
"mUsername = $_POST['Username'], " . // selected USERNAME
"mPassword = $_POST['encrypted_password']"; // selected PASSWORD
$result = mysql_query($query) or die ("Error in query: $query. " . mysql_error());
$memberID = mysql_insert_id();
// generate and execute query 2
$query2 = "INSERT INTO Lookup SET " .
"relMemberID = '$memberID', " . // member ID
"relReligionID = 'religion', " . // religion (hidden field)
"relRelationID = 'relation_id', ". // relationship of person posting profile to member
"relMStatus = '$mstatus_id', " . // marital status
"relHeightID = '$height_id', " . // height
"relBuildID = '$build_id', " . // build
"relComplexionID= '$complexion_id', " . // complexion
"relCBirthID = '$country_id1', " . // country of origin
"relCOriginID = '$country_id2', " . // country of birth
"relEducationID = '$education_id', " . // education
"relOccupationID= '$occupation_id', " . // occupation
"relDietID = '$diet'"; . // diet
$result2 = mysql_query($query2) or die ("Error in query 2: $query2. " . mysql_error());
Finally, write a simple form to fill in:PHP Code:} else {
// 1. relation query /////
$relation_query = mysql_query("SELECT relationID, relationType FROM Relation" );
// 2. marital status query /////
$mstatus_query = mysql_query("SELECT mstatusID, statusType FROM MStatus" );
// 3. height query /////
$height_query = mysql_query("SELECT heightID, heightCM, heightValue FROM Height ORDER BY heightCM" );
// 4. build query /////
$build_query = mysql_query("SELECT buildID, buildType FROM Build" );
// 5. complexion query /////
$complexion_query = mysql_query("SELECT complexionID, complexionType FROM Complexion" );
// 6. country query /////
$country_query = mysql_query("SELECT countryID, countryName FROM Country" );
// 7. education query /////
$education_query = mysql_query("SELECT educationID, educationType FROM Education" );
// 8. occupation query /////
$occupation_query = mysql_query("SELECT occupationID, occupationName FROM Occupation" );
?>
STAGE THREEPHP Code:<FORM ACTION="<?php echo($_SERVER['PHP_SELF']); ?>" METHOD="POST">
<DIV ALIGN="CENTER">
<TABLE CELLSPACING="2" CELLPADDING="2" BORDER="0" WIDTH="98%">
... various fields...
<TR VALIGN="middle">
<TD>Profile created by:</TD>
<TD> <SELECT NAME="relation_select" alt="select" />
<OPTION SELECTED VALUE="">-----------</OPTION>
<?php
while ($rel_q = mysql_fetch_array($relation_query)) {
$relation_id = $rel_q["relationID"];
$relation_title = $rel_q["relationType"];
echo("<OPTION VALUE='$relation_id'>$relation_type<BR>\n" );
}
?>
</SELECT> </TD>
...etc.. for the other queries..
Okay, so I load it up in the browser, and it all displays.. way hey!But then I look at some of the fields that should contain information from the database but there is nothing in there???
![]()
Am I doing something wrong with the mysql_fetch_array???
Does the the rest of it look okay or am I doing something wrong???
So.. can anyone helps please?
Thanks.
Mak![]()



But then I look at some of the fields that should contain information from the database but there is nothing in there???

/TD
That worked!


Bookmarks