Jump to content

already exist dont display


skyhighweb

Recommended Posts

 

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

 

the 4 below appears 2twice in both columns need the code to check both columns not minding where the data is in the row and wont display it in the result

 

bidder tagged

 

4 5

 

2 0

 

6 4

 

thats the code am using 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');

Link to comment
Share on other sites

1 - do you have php error checking turned on?

2 - you don't show much REAL code so it's hard to see what may be going wrong.

3 - Try using caps and periods and forming separate sentences to help us understand what you are saying

4 - do you check the query results to be sure it ran? To see how many rows were returned?

5 - have you done any debugging by displaying variables or your query string to be sure things are as you assume they are?

 

 

(see my signature for error checking code)

 

PS - use the proper forum tags to post code next time.

Link to comment
Share on other sites

$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++;

}

 

hi thats the full code am using i just a code to implement that will check both bidder and tagged tto see if a value is in both column and if it is shouldn't display that value in the result

Link to comment
Share on other sites

Please read my first post and abide by the things I pointed out.

 

In addition:

 

1 - read the manual for the definition of Fetch and Fetchall

2 - think about the bidderarray you are building.  You are assigning the key and value as the same things.  What's the point?

Edited by ginerjm
Link to comment
Share on other sites

using 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 ('bidder')

 

like i said am not as good as u programmers, php can be something else, well unto the next coding issue that i will soon find. will b bugging u guys soon again

Edited by skyhighweb
Link to comment
Share on other sites

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.