Results 1 to 5 of 5

Thread: Adding Listing, Selecting own User?

  1. #1
    Join Date
    May 2004
    Posts
    7

    Default

    I'm transforming the searchengine to a searchengine for products. The goal is to display a product WITH the information of the company which is selling the product.

    So the idea was to ad a company as an agent, beceause the agents information can be displayed with te product. I've deleted some information from the 'add_user' file. This works fine. I just log in as Admin, create an agent (new company) and add a listing. But in order to display the correct company with the listing I have to go to 'edit listing' and change the user which created the listing.

    So I just copied the source code which is responsible for changing the agent/user:
    Code:
    <tr><td align="right"><b><?php echo $lang&#91;user_editor_user_number&#93; ?>&#58;</b></td>
                   <td align="left" class="row_main"><select name="owner" size="1">
    			<?php	
    				// find the name of the agent listed as ID in $edit_owner
    				$sql="SELECT user_name FROM " . $config&#91;table_prefix&#93; . "UserDB WHERE &#40;ID = '$edit_owner'&#41;";
    				$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
    				$recordSet = $conn->Execute&#40;$sql&#41;;
    				if &#40;$recordSet === false&#41;
    				&#123;
    					log_error&#40;$sql&#41;;
    				&#125;
    
    				//strip slashes so input appears correctly
    				$edit_owner_name = make_db_unsafe &#40;$recordSet->fields&#91;user_name&#93;&#41;;
    				echo "<option value=\"$edit_owner\">$edit_owner_name</option>";
    				// fill list with names of all agents
    				$sql="SELECT ID, user_name FROM " . $config&#91;table_prefix&#93; . "UserDB where isAgent = 'yes' ORDER BY user_name";
    				$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
    				$recordSet = $conn->Execute&#40;$sql&#41;;
    				if &#40;$recordSet === false&#41;
    				&#123;
    					log_error&#40;$sql&#41;;
    				&#125;
    				while &#40;!$recordSet->EOF&#41;
    				&#123;
    					//strip slashes so input appears correctly
    					$agent_ID = $recordSet->fields&#91;ID&#93;;
    					$agent_name = make_db_unsafe &#40;$recordSet->fields&#91;user_name&#93;&#41;;
    					echo "<option value=\"$agent_ID\">$agent_name</option>";
    					$recordSet->MoveNext&#40;&#41;;
    				&#125;
    				echo "</select></TD>";
    			?>
    This had no effect, it created the choice to select a user/agent (company) but doens't save it, so I still have to edit the listing in order to display the correct company.

    How can I edit my 'add_listings' file in order to make it save my user choice?

    (My apology for my English)

  2. #2
    Join Date
    Apr 2003
    Location
    Charleville / Australia
    Posts
    1,421

    Default

    There is nowhere in the code you show that saves the info to the database only the ability to show it.
    you will need to add the sql statement that saves the field or edit the current statement to include the field.

  3. #3
    Join Date
    May 2004
    Posts
    7

    Default

    Yes, but I also can't find where the program looks for which user is logged on, I'm a newbie, but only need to know some parts.

    In the adding the SQL-code from 'edit_listing' doesn't change anything, it only add's the link to 'edit_listing' How to add user change to a file? that also does that, but I don't know where :(

  4. #4
    Join Date
    Apr 2003
    Location
    Charleville / Australia
    Posts
    1,421

    Default

    Reading the above code i can see that it is calling the new select options as
    agent_name and agent_id

    So your select is offering you the agents name and ID in a format that would not be known by the current page.

    you need to find the sql statement that is inserting the info to the database and make sure that it is ready to accept agent_id instead of the userID which is the default.
    the following is just to show you.
    $sql = "INSERT INTO ".$config['table_prefix']."listingsDB (user_ID, active,) VALUES ('$agent_ID',

    the database table requires the first mention since that is the coloum to put it in but if the second mention is also user_ID or anything simlar you must change it to match the name your new statement has given so it becomes agent_id.
    you may alos find the same used as a global on the page (if not it should be) this also needs to be made agent_ID.

  5. #5
    Join Date
    May 2004
    Posts
    7

    Default

    Alright, I managed to edit the 'add_listing' and the 'edit_my_listing' file. Both accept the agent_ID. But there is 1 problem. When selecting an agent the program doesn't add it to the SQL database. It doesn't add the admin anymore, but now it doesn't add anything, so not the agent I selected.

    add_listing.php
    Code:
    global $HTTP_POST_VARS, $pass_the_form, $agent_ID;
    Code:
    $sql = "INSERT INTO " . $config&#91;table_prefix&#93; . "listingsDB &#40;title, notes, user_ID, active, mlsimport, creation_date, last_modified, expiration&#41; VALUES &#40;$title, '$random_number',  '$agent_ID', '$set_active', $mlsimport, ".$conn->DBDate&#40;time&#40;&#41;&#41;.",".$conn->DBTimeStamp&#40;time&#40;&#41;&#41;.",".$conn->DBDate&#40;$expiration_date&#41;."&#41;";
    Code:
    $message = updateListingsData&#40;$new_listing_id, $agent_ID&#41;;
    				if &#40;$message == "success"&#41;
    				&#123;
    					echo "<p>$lang&#91;admin_new_listing_created&#93;, $agent_name</p>";
    					
    					if &#40;$config&#91;moderate_listings&#93; == "yes"&#41;
    					&#123;
    edit_my_listing.php:

    Code:
    if &#40;$edit != ""&#41;
    	&#123;
    		$sql_edit = make_db_safe&#40;$edit&#41;;
    		// first, grab the listings's main info
    		$sql = "SELECT ID, title, notes, last_modified, featured, active, mlsimport, expiration FROM " . $config&#91;table_prefix&#93; . "listingsDB WHERE &#40;&#40;ID = $sql_edit&#41; AND &#40;user_ID = '$agent_ID'&#41;&#41;";

Similar Threads

  1. New listing_add.php which restricts posts to N
    By awddesign in forum Mods (CLOSED)
    Replies: 27
    Last Post: 09-10-2004, 08:30 PM
  2. Replies: 1
    Last Post: 04-11-2004, 07:44 PM
  3. Couple questions... - ANSWERED
    By hbaker in forum HELP (CLOSED)
    Replies: 12
    Last Post: 11-12-2003, 12:42 AM
  4. Selecting Agent upon New Listing
    By Anonymous in forum HELP (CLOSED)
    Replies: 2
    Last Post: 08-07-2003, 09:18 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •