Jump to content

Recommended Posts

Hi,  I'm having a little trouble  :-\

 

SOLVED IT - I'm such a muppet - all I had to do was DISTINCT on the first item in the query (jos_comprofiler.user_id) and it works.  Sorry!  :-[

 

I've created a system to allow people to register interest in items for sale prior to 'release'.  They do this over the phone, and an administrator basically ticks off the items and it gets stored into a database:

 

id / item_id / client_id

 

I did this so that more than one person can be interested is the same item.  However, when creating a dropdown with names based on client_id, I get multiple names.  As I'm using a join across the tables, I can't figure how I'm going to allow it to be distinct names, or is there another way?

 

Here's the db query:

    $view_telebidders = "SELECT jos_comprofiler.user_id, firstname, lastname ";
    $view_telebidders .= "FROM jos_comprofiler ";
    $view_telebidders .= "LEFT JOIN jos_bid_telebids ";
    $view_telebidders .= "ON bidder_id ";
    $view_telebidders .= "WHERE jos_bid_telebids.bidder_id = jos_comprofiler.user_id ";
    $view_telebidders .= "ORDER BY lastname ASC";
    $res_telebidders = mysql_query($view_telebidders) or die(mysql_errno() . mysql_error());

    // GENERATE
    $row_select_telebidders = mysql_fetch_assoc($res_telebidders);
$totalRows_select_telebidders = mysql_num_rows($res_telebidders);

 

And here's the dropdown:

		<td><select name="teleselect" onchange="this.form.submit()">
		<option value='none'>-- Select Telephone Bidder --</option>
			<?php
				do {

						if ($useridassign==$row_select_telebidders['user_id']) {
							echo "<option value ='".$row_select_telebidders['user_id']."' selected>".$row_select_telebidders['firstname']." ".$row_select_telebidders['lastname']."</option>";
						} else {
							echo "<option value ='".$row_select_telebidders['user_id']."'>".$row_select_telebidders['firstname']." ".$row_select_telebidders['lastname']."</option>";
						}

					} while ($row_select_telebidders = mysql_fetch_assoc($res_telebidders));

						$rows = mysql_num_rows($res_telebidders);
						if($rows > 0) {
						mysql_data_seek($res_telebidders, 0);
						$row_select_telebidders = mysql_fetch_assoc($res_telebidders);

						}
			?>
	</select></td>

 

Last, but not least, source code of the output, so you can see the duplicates:

 

<td><select name="teleselect" onchange="this.form.submit()">
<option value='none'>-- Select Telephone Bidder --</option>
<option value ='7797'>Robert Bringham</option>
<option value ='7814'>Johan Hansson</option>
<option value ='7814'>Johan Hansson</option>
<option value ='7820'>Stephen Smith</option>
<option value ='7820'>Stephen Smith</option>		
</select></td>

 

It's odd that Robert Bringham only comes up once.  What's gone wrong?  :( ???

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.