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'); 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. 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 Link to comment Share on other sites More sharing options...
ginerjm Posted May 4, 2017 Share Posted May 4, 2017 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? 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 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. Link to comment Share on other sites More sharing options...
skyhighweb Posted May 5, 2017 Author Share Posted May 5, 2017 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.