diff --git a/html/user/profile_menu.php b/html/user/profile_menu.php
index f798da4655..3d3b916c44 100644
--- a/html/user/profile_menu.php
+++ b/html/user/profile_menu.php
@@ -2,6 +2,7 @@
require_once("util.inc");
require_once("project.inc");
+require_once("gallery.inc");
db_init();
@@ -12,21 +13,32 @@ if ($_GET['cmd']) {
page_head("Profile Zone");
-
-
start_table_noborder();
-row1("User Profiles");
+rowify("
+User profiles provide a way for individuals to share backgrounds and opinions with the " . PROJECT . " community. Explore the diversity of your fellow searchers, and contribute your own views for others to enjoy.
+
+If you haven't already, you can create your own user profile for others to see!
+");
+rowify("
");
+row1("User Profile Explorer");
rowify("
");
-row1("Search");
+
+// TODO: Create management page with links to generate galleries.
+// [Generate]
+// [Generate]
+
+rowify("
");
+row1("Name Search");
+rowify("
");
end_table();
echo "
@@ -43,13 +55,12 @@ function execute_command() {
// Request for a random profile.
if ($_GET['cmd'] == "rand") {
- if ($_GET['pic']) {
- if ($_GET['pic'] == 0) {
- $result = mysql_query("SELECT userid FROM profile WHERE has_picture = 0");
- } else if ($_GET['pic'] == 1) {
- $result = mysql_query("SELECT userid FROM profile WHERE has_picture = 1");
- }
- } else {
+
+ if ($_GET['pic'] == 0) {
+ $result = mysql_query("SELECT userid FROM profile WHERE has_picture = 0");
+ } else if ($_GET['pic'] == 1) {
+ $result = mysql_query("SELECT userid FROM profile WHERE has_picture = 1");
+ } else if ($_GET['pic'] == -1) {
$result = mysql_query("SELECT userid FROM profile");
}
@@ -66,16 +77,35 @@ function execute_command() {
else if ($_GET['cmd'] == "search") {
if ($_GET['name']) {
- $result = mysql_query("SELECT id FROM user WHERE name = " . $_GET['name']);
- if ($result) {
- while ($row = mysql_fetch_row($result)) {
- echo "
ID ", $row['0'], " has a name that matches your query.";
+ $result = mysql_query("SELECT id FROM user WHERE name LIKE \"%" . $_GET['name'] . "%\"");
+
+ while($row = mysql_fetch_assoc($result)) {
+ $result2 = mysql_query("SELECT userid FROM profile WHERE userid = " . $row['id']);
+ if ($result2) {
+ $row2 = mysql_fetch_assoc($result2);
+
+ if ($row2['userid']) {
+ $members[] = $row2['userid'];
+ }
}
- } else {
- echo "No names matched your query.
";
}
+
+ show_search_results($members);
}
}
}
+function show_search_results($members) {
+ page_head("Profile Search Results");
+
+ if (count($members) > 0) {
+ show_user_table($members, 0, 10, 2);
+ } else {
+ echo "No profiles matched your query.
";
+ }
+
+ page_tail();
+
+}
+
?>
\ No newline at end of file