
Originally Posted by
Mandes
Jeffs virtually told you everything :-)
And yet I still have questions!!!
Okay, here is the query that gives me a number that I want to turn into either Male/Female...
Code:
// Check # of Records Returned.
if (mysqli_stmt_num_rows($stmt1)==1){
// Member was Found.
// Bind result-set to variables.
mysqli_stmt_bind_result($stmt1, $firstName, $username, $photoName, $photoLabel,
$gender, $birthYear, $location,
$occupation, $interests, $aboutMe);
And here is an attempt at my first-ever Function...
PHP Code:
function displayGender($gender){
if ($gender == 1){
$gender = 'Male';
}elseif ($gender == 2){
$gender = 'Female';
}else{
$gender = '';
}
return $gender;
}//End of displayGender
Questions:
1.) Will I get into trouble have a variable called $gender in my query-set AND labeling the Function's Parameter $gender as well?
2.) Do you have any naming convention on this topic?
3.) I purposely used $gender throughout my code, but I am wondering what is a better way to do things?
Or could I get away with what I did?
Personally I suggest that you create a seperate php file and put all your functions in there, then reference that file at the top of your scripts. It means a) you know where to find them, b) they then dont bloat your main script and c) you can take that file with you to your next project and have all those useful functions to use straght away.
I created a directory called utilities and in it a file called functions.php
Thoughts?
Debbie
Bookmarks