Already exist dont display

need a help with a PHP/MySQL issue. I have a table named bids and two column named bidder and tagged both using int.

I’m trying to detect multiple same entry number. I want if a number appears on both of the columns it shouldnt display on the menu list anymore

for example

if the number 4 are in both column

bidder tagged

4 5

2 0

6 4

the 4 above appears like that in the column need the code to check both columns not minding where the data is in the row and not display in the result,

my codes are below

$query = "SELECT b.auction, b.bidder, b.bid, b.tagged, u.nick, u.rate_sum FROM " . $DBPrefix . "bids b

LEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder) WHERE b.auction = :auc_id

ORDER BY b.bid asc, b.quantity DESC, b.willwin asc"; $params = array(); $params[] = array(':auc_id', $id, 'int');

$i = 0;
$hbidder_data = array();
foreach ($db->fetchall() as $bidrec)
{
	if (!isset($bidderarray[$bidrec['nick']]))
	{
		if ($system->SETTINGS['buyerprivacy'] == 'y' && (!$user->logged_in || ($user->user_data['id'] != $auction_data['user'] && $user->user_data['id'] != $bidrec['bidder'])))
		{
			$bidderarray[$bidrec['nick']] = $bidrec['nick'];
			$bidderarraynum++;
		}
		
	}
	
	$template->assign_block_vars('tag_bidder', array(
			'BGCOLOUR' => (!($i % 2)) ? '' : 'class="alt-row"',
			'ID' => $bidrec['bidder'],
			'NAME' => $bidderarray[$bidrec['nick']]
			
			));
	$i++;
}

any help?

I’m struggling to see how the list of two numbers relates to the code you posted. I think the way I’d do it is run down each element in the first column and see if it exists anywhere in the second column, and if it does, remove it from the menu. That would be quite easy if you have three separate arrays - one containing the first column, another containing the second, and a third containing the menu list contents. How feasible that is depends on how many entries there will be in those two columns of numbers.

cool the issue is i dont know how to code that u think u can implement the code in the above code?

beside the code aabove is what i use to display the list

You have a big problem if you don’t know to code. @droopsnoot gave you solution.

1 Like

saying it is one thing doing it is another u know

Exactly. So you can start doing your job.

1 Like

well am a beginner, came to seek assistance, telling me what to do isnt gonna make a diff, thank yyou

hi can u kindly assist that will b nice

oh and they dont relate thats the code i use to list users and also remove a users name from the list(users viewing a page dont get to see there own name on it) only other names.

foreach over your array. remember every left-value in an array $lefts.
if you need the comparison in both directions, put the right value in $rights.
foreach over your array again. if the right value is in_array() the $lefts, store the number in a seperate array $excludes. if the left value is in the $rights, also store the number in $excludes.
that’s not very efficient (array_column()/array_intersect()/array_diff() may help), but will do the job.

OK, but that isn’t clear. The query and code you posted doesn’t look like the code of a beginner. It’s often difficult to tell how much knowledge a poster has. Perhaps you could start by posting the code that generates the list of two columns of numbers that you want to search through.

thanks alot people i did this SELECT * FROM table WHERE col1 NOT IN (SELECT col2 FROM table)

WHERE bidder NOT IN (SELECT tagged FROM bids)

but rewrote the code to

WHERE bidder NOT IN (‘tagged’) and tagged IN (‘b.bidder’)

php can be something else, well unto the coding issue

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.