View Full Version : user specifies in the search
Anonymous
04-26-2003, 08:47 PM
as view every list of registrations alone of an user specifies
in the search result?
greengiant
04-30-2003, 05:21 PM
I'm sorry I do not understand your question
verdon
04-30-2003, 08:34 PM
I think he might be asking about searching by user?? I have done this for a client site I am working on now. The edits weren't too too bad... I'll try to dig through my notes and post it here. I've done so much monkeying in listingsearch.php that I won't be able to offer exact line numbers, but I should be able to offer some assistance. I'll come back tomorrow.
Here's some examples of what I think he's asking...
http://dev.lacmedia.ca/members/listing_browse.php
http://dev.lacmedia.ca/members/view_users.php
Anonymous
05-04-2003, 11:30 PM
verdon,
I was wondering is it possible to make a search page which when select the price, subject and medium will only pull out related to that member.
for example
http://dev.lacmedia.ca/members/listing_browse.php
a search page for arthur artist which would not have member selection field but which would have rest of the field relating to arthur artist. or when some one selects medium, subject etc would bring only which is by arthur artist.
verdon
05-05-2003, 10:27 AM
There's a few steps involved. If you're comfortable mucking in the php go for it. I'll try to outline what I did below. I've done a lot of other customizing to my files and they are not the same as what Ryan is so graciously maintaining here, so I won't be able to accurately provide line numbers. Hopefully I'll be able to document it clearly enough and this will be of use to someone. Best luck...
First, to support users in listingsearch.php I had to add the following 3 areas. Note: I called the variable 'Member' instead of 'User' because when I originally called it user, I was getting interference from a value for user stored in a cookie from another part of the same site.
a) somewhere near line 19-20 look for the line
$sql = "CREATE TEMPORARY TABLE temp SELECT listingsDB.ID, listingsDB.Title, listingsDBElements.field_name, listingsDBElements.field_value FROM listingsDB, listingsDBElements WHERE (listingsDBElements.listing_id = listingsDB.ID) AND ";
and add just after it
if ($Member)
{
$sql .= "(listingsDB.user_ID = '$Member') AND ";
}
so it looks like
$sql = "CREATE TEMPORARY TABLE temp SELECT listingsDB.ID, listingsDB.Title, listingsDBElements.field_name, listingsDBElements.field_value FROM listingsDB, listingsDBElements WHERE (listingsDBElements.listing_id = listingsDB.ID) AND ";
if ($Member)
{
$sql .= "(listingsDB.user_ID = '$Member') AND ";
}
b) a little further down, near line 40-44 look for
elseif ($ElementIndexValue == "PHPSESSID")
{
// do nothing
}
and add just after it
elseif ($ElementIndexValue == "Member")
{
$guidestring .= "$ElementIndexValue=$ElementContents&";
}
c) and much further down (sorry my line numbers will be of no use) look for
else
{
$ElementIndexValue = make_db_safe($ElementIndexValue);
$ElementContents = make_db_safe($ElementContents);
$select_statement = "SELECT ID FROM temp WHERE ( (field_name = $ElementIndexValue) AND (field_value = $ElementContents) )";
$recordSet = $conn->Execute($select_statement);
if ($recordSet === false) log_error($select_statement);
$save_array = array();
and just above this add
elseif($ElementIndexValue == "Member") {
next;
}
note: there should already be a number of elseif statements in this area. You are just adding another possible scenario befor the final else statement.
Second, add the following function to your style.php file
function searchbox_select_user ($browse_caption)
{
// builds a multiple choice select box for searching by Member
// to let users search by
global $conn, $config;
echo "<tr><td align=\"right\"><b>$browse_caption</b></td>";
echo "<td align=\"left\"><select name=\"Member\" size=\"5\" multiple>";
$sql = "SELECT UserDB.user_name, UserDB.ID, listingsDB.user_ID, listingsDB.ID, count(user_name) AS num_type FROM UserDB, listingsDB WHERE listingsDB.active = 'yes' AND UserDB.ID = listingsDB.user_ID ";
if ($config[use_expiration] == "yes")
{
$sql .= " AND expiration > ".$conn->DBDate(time());
}
$sql .= "GROUP BY UserDB.user_name ORDER BY UserDB.user_name";
$recordSet = $conn->Execute($sql);
if ($recordSet === false) log_error($sql);
while (!$recordSet->EOF)
{
$field_output = make_db_unsafe ($recordSet->fields[user_name]);
$field_output2 = make_db_unsafe ($recordSet->fields[user_ID]);
$num_type = $recordSet->fields[num_type];
echo "<option name=\"Member\" value=\"$field_output2\">$field_output ($num_type)";
$recordSet->MoveNext();
} // end while
echo "</select></td></tr>";
} // end function searchbox_select_user
Third, add the following snippet to listing_browse.php, inside the form area, wherever you want the form element to be
<? searchbox_select_user ("Member") ?>
and that should do it :-)
Finally, to answer varkey's question... I suppose that instead of including the call to searchbox_select_user() in listing_browse.php: if you wanted a search page specific to one user only, you could save a copy of listing_browse.php as something like user_name_browse.php. Then instead of calling searchbox_select_user() you could add a hidden form element along the lines of
<input type="hidden" name="Member" value="35">
<!-- value would be the user ID you wish to search against -->
I haven't tried that, but it should work.
salut,
Anonymous
05-05-2003, 10:41 PM
Verdon,
Thankyou very much for the solution. I just tried it. It works fine.
thankyu once again.
varkey
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.