Okay at the moment I have code that shows all members and lets you click a members username and then it will display the text MEMBER to confirm a member has been selected, if not it will say member does not exist.
But, I want to make it so I can search for the member.
Using a post, but I cant get it to work, every-time I change the query and search, it finds the member but when I click it it states the member cannot be found,
I want you to be able to put in a text box a user name such as 'bioshox' it will show the member with the name bioshox, you can then click it and it will show you the profile, but at the moment it showing all members and working off ID's not member names.
//Defines The Function Name
//And declaired $id does not have a value
function get_content($id = '') {
//If $id dosent have a value
if($id !=""):
$username = $_POST['username'];
$id = mysql_real_escape_string($id);
//When the variable is declaired $id, it will select everything from regusers where that $id was declaired
$sql = "SELECT * FROM users where id = '$id'";
else:
//If a member hasent been selected, display everything in accending order
$sql = "SELECT * FROM users ORDER BY username ASC";
endif;
//Carry out the query on $sql If an error occoured, tell us
$res = mysql_query($sql) or die(mysql_error());
//If the ammount of rows is not the same as 0
if(mysql_num_rows($res) != 0):
//Defines the variable to carry out the query
while($row = mysql_fetch_assoc($res)) {
//Makes members names into links
//IF a member has been selected, then display the About Me row from the Database
if ($_GET['member']):
echo "MEMBER";
else:
echo '<h3><li><a href="search.php?member=' . $row['id'] . '">' . $row['username'] . '</a></h3>';
endif;
//Ends the while statment
}
//If the ammount of rows is the same as 0 which means the member did not exist, display an error message
else:
echo '<h3>That member dosent seem to exist!<br><br><a href="members.php">Back To Members</a></h3>';
endif;
//End's the function
}
//Defines how to display the members
//If a member has been selected then
if(isset($_GET['member'])):
//Get a single member
get_content($_GET['member']);
else:
//Get all members and display total
get_content();
endif;
?>


Sign In
Create Account


Back to top









