skyhighweb Posted May 4, 2017 Share Posted May 4, 2017 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'); Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 4, 2017 Share Posted May 4, 2017 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. Quote Link to comment Share on other sites More sharing options...
skyhighweb Posted May 4, 2017 Author Share Posted May 4, 2017 $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 Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 4, 2017 Share Posted May 4, 2017 (edited) 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 May 4, 2017 by ginerjm Quote Link to comment Share on other sites More sharing options...
skyhighweb Posted May 5, 2017 Author Share Posted May 5, 2017 that bidarray will not show a user there own name when they are viewing the list of name it will only show others Quote Link to comment Share on other sites More sharing options...
ginerjm Posted May 5, 2017 Share Posted May 5, 2017 Apparently my queries are not being read properly. I'll stop making them. Quote Link to comment Share on other sites More sharing options...
skyhighweb Posted May 5, 2017 Author Share Posted May 5, 2017 (edited) 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 May 5, 2017 by skyhighweb Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.