Results 1 to 2 of 2

Thread: Database join question.

  1. #1
    Join Date
    Feb 2003
    Posts
    13

    Default

    I am trying to a multiple join and it is working but I am having a problem with the ID field. It is pulling the ID from the listingDBElements table instead of the one I want. Can you please direct me on what I am doing wrong. It is assigning the $listingID= userID which I don't want.
    Anyway here is my code if you can help I want to get the id of the add placed:
    Code:
    <?php
    	$id = $_SESSION&#91;'userID'&#93;;
    	$sql = "SELECT AgentDB.ID, favs.vid, favs.uid, listingsDB.Title, listingsDBElements.field_value, listingsDBElements.field_name FROM AgentDB, favs, listingsDB, listingsDBElements WHERE AgentDB.ID = '$id' AND  favs.uid = AgentDB.ID AND listingsDBElements.listing_id = favs.vid AND listingsDBElements.field_name = 'Catagory' AND listingsDB.ID = favs.vid";
    		$recordSet = $conn->Execute&#40;$sql&#41;;
    		if &#40;$recordSet === false&#41;
    		&#123;
    			log_error&#40;$sql&#41;;
    		&#125;
    		$returned_num_listings = $recordSet->RecordCount&#40;&#41;;
    													 if &#40;$returned_num_listings == 0&#41;
    													 		&#123;
    															echo "You do not have any favorites";
    															&#125;
    																																
    		while &#40;!$recordSet->EOF&#41;
    		&#123;
    		 	$listingID = make_db_unsafe &#40;$recordSet->fields&#91;ID&#93;&#41;;
    			$title = make_db_unsafe &#40;$recordSet->fields&#91;Title&#93;&#41;;
    			$make = make_db_unsafe &#40;$recordSet->fields&#91;field_value&#93;&#41;;
    			$field_caption = make_db_unsafe &#40;$recordSet->fields&#91;field_caption&#93;&#41;;
    			$field_value = make_db_unsafe &#40;$recordSet->fields&#91;field_value&#93;&#41;;
    			echo "<a href=\"http&#58;//motorcycleshopper.com/v5/listingview.php?listingID=$listingID\">$title</a> $field_value";
    			echo "<form name=\"form1\" method=\"post\" action=\"showall.php\"><input name=\"action\" type=\"hidden\" id=\"action\" value=\"deletefav\" /><input type=\"checkbox\" name=\"vid\" value=\"$listingID\"><input type=\"submit\" name=\"Submit\" value=\"delete\"></form><br />";			
    			$recordSet->MoveNext&#40;&#41;;
    		&#125;					
    ?>

  2. #2
    Join Date
    Feb 2003
    Posts
    13

    Default

    Ok I got it to work Don't you just love fixing your own errors.

    Anyway I had the select wwaaayyy to bloated. I used this instead:
    Code:
    $sql = "SELECT * FROM favs, listingsDB WHERE favs.uid = '$id' AND listingsDB.ID = favs.vid";
    However with this method I can't pull the values I want out of listingDBElements. So if you have any ideas on this please let me know.

Similar Threads

  1. reinstalling database
    By johnnyrealty in forum HELP (CLOSED)
    Replies: 5
    Last Post: 03-10-2005, 09:41 AM
  2. Noob question about DATABASE CONFIGURATION
    By XIII in forum HELP (CLOSED)
    Replies: 12
    Last Post: 03-09-2005, 10:46 PM
  3. Making the first database. All I have is FileMaker Pro.
    By Anonymous in forum HELP (CLOSED)
    Replies: 9
    Last Post: 01-23-2004, 02:11 PM
  4. database error(solved)
    By Anonymous in forum HELP (CLOSED)
    Replies: 5
    Last Post: 09-08-2003, 04:06 PM
  5. Database Connectivity.....?
    By Baby Bear in forum HELP (CLOSED)
    Replies: 0
    Last Post: 05-30-2003, 10:53 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
  •