skyhighweb
-
Posts
86 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by skyhighweb
-
-
thats the code i use for insert updating it doesnt work fine
-
good morning all, here is the complete code
$query = "SELECT b.*, u.nick FROM " . $DBPrefix . "bids b LEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder) WHERE b.bidder NOT IN ('b.tagged') and b.tagged IN ('b.bidder') and b.auction = :auc_id "; $params = array(); $params[] = array(':auc_id', $id, 'int'); $db->query($query, $params); // Also update bids table $query = "INSERT INTO " . $DBPrefix . "bids VALUES (NULL, :auc_id, :bidder_id, :bid, :time, :qty, :willwin, :tagged, :balance)"; $params = array(); $params[] = array(':bid', $bid, 'float'); $params[] = array(':auc_id', $id, 'int'); $params[] = array(':bidder_id', $bidder_id, 'int'); $params[] = array(':time', $NOW, 'int'); $params[] = array(':qty', $qty, 'int'); $params[] = array(':willwin', $willwin, 'str'); $params[] = array(':tagged', $tagged, 'str'); $params[] = array(':balance', $balance, 'str'); $db->query($query, $params); $i = 0; while ($row = $db->fetch()) { $template->assign_block_vars('tag_bidder', array( 'ID' => $row['bidder'], 'NAME' => $row['nick'], 'WILLWIN' => $row['willwin'], 'TAGGED' => $row['tagged'] )); $i++; }
-
i have tried updating but it doesnt work
i tried this bids
set tagged = (bidder)
the data looks like this
bidder......tagged
david ..... david
mike ..... davidinstead of
bidder......tagged
david ..... mike
mike ..... david -
help still needed
-
hi programmer i have an issue here.
so let me explain better, if david place a bid but doesnt tag any one the column looks like thisbidder......tagged
david ..... 0and if someone else(mike), place a bid and tag david
the column look like this
bidder......tagged
Mike ..... davidthis shows both mikes and david rows
bidder......tagged
david ..... 0
mike ..... davidu can see david row doesnt update, it should show mike and not 0, hope u understand.
below is the code am using to fill the form
// tag someone
$query = "SELECT b.*, u.nick FROM " . $DBPrefix . "bids b
LEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder)
WHERE b.bidder NOT IN ('b.tagged') and b.tagged IN ('b.bidder') and b.auction = :auc_id ";
$params = array();
$params[] = array(':auc_id', $id, 'int');
$db->query($query, $params);$i = 0;
while ($row = $db->fetch())
{
$template->assign_block_vars('tag_bidder', array(
'ID' => $row['bidder'],
'NAME' => $row['nick'],
'TAGGED' => $row['tagged']
));
$i++;
} -
any idea how to go about this
-
hello programmers am having an update issue and i dont know how to go about it am gonna try n explain it the way i can plz bear with me.
i have a table called bids and two important column called bidder and taggedwhen (bidder 5) has no one to tag he simple drops a bid and when another bidder comes along(bidder 3) he tags (bidder 5) i want bidder 5 row to update showing (bidder 3)in his row.
for example
bidder 5 place bid it looks like this
bidder tagged
5 0no one to tag so it shows zero
i want if bidder 5 get tagged by bidder 3 it update showing the person that tag bidder 5 and it will look like this
bidder tagged
5 3from the image i attached u can simply understand what am saying.
looking forward to ur replies thanks
code i am using to fill the form is below
// tag someone $query = "SELECT b.*, u.nick FROM " . $DBPrefix . "bids b LEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder) WHERE b.bidder NOT IN ('b.tagged') and b.tagged IN ('b.bidder') and b.auction = :auc_id "; $params = array(); $params[] = array(':auc_id', $id, 'int'); $db->query($query, $params); $i = 0; while ($row = $db->fetch()) { $template->assign_block_vars('tag_bidder', array( 'ID' => $row['bidder'], 'NAME' => $row['nick'], 'TAGGED' => $row['tagged'] )); $i++; }
-
19 hours ago, justsomeguy said:
There are several ways you can handle this. You can do everything in SQL, or like already suggested you can also just get a list of the values in one column and then filter things out in PHP. If you're just starting out and you haven't learned SQL then this isn't going to make a lot of sense.
SELECT * FROM table WHERE col1 NOT IN (SELECT col2 FROM table)
Look at that and try to understand what it's doing, it will select everything from the table except rows where the value in col1 is in any other row in col2 in the same table. It sounds like that's what you're looking for, hopefully you can adapt that to your database.
the simple code seem to help i did it this was thou
WHERE col1 NOT IN (' col2 ') and col2 IN (' col2 ')
-
13 minutes ago, skyhighweb said:
but not working well
-
8 minutes ago, skyhighweb said:
I TRIED that WHERE bidder NOT IN ('tagged') and tagged IN ('bidder')";
but not working well
-
18 hours ago, justsomeguy said:
There are several ways you can handle this. You can do everything in SQL, or like already suggested you can also just get a list of the values in one column and then filter things out in PHP. If you're just starting out and you haven't learned SQL then this isn't going to make a lot of sense.
SELECT * FROM table WHERE col1 NOT IN (SELECT col2 FROM table)
Look at that and try to understand what it's doing, it will select everything from the table except rows where the value in col1 is in any other row in col2 in the same table. It sounds like that's what you're looking for, hopefully you can adapt that to your database.
i think i got it using ur idea still running to see nothing freaking is on, i did this
WHERE bidder NOT IN ('tagged') and tagged IN ('bidder')";
-
29 minutes ago, skyhighweb said:
i tried what u gave me but no result, i implemented it like this
$query = "SELECT * FROM bids WHERE bidder NOT IN (SELECT tagged FROM bids)";
$params = array();
$db->query($query, $params);$i = 0;
while ($row = $db->fetch())
{
$template->assign_block_vars('tag_bidder', array(
'BGCOLOUR' => (!($i % 2)) ? '' : 'class="alt-row"',
'ID' => $row['bidder'],
'TAGGED' => $row['tagged']
));
$i++;
} -
18 hours ago, justsomeguy said:
There are several ways you can handle this. You can do everything in SQL, or like already suggested you can also just get a list of the values in one column and then filter things out in PHP. If you're just starting out and you haven't learned SQL then this isn't going to make a lot of sense.
SELECT * FROM table WHERE col1 NOT IN (SELECT col2 FROM table)
Look at that and try to understand what it's doing, it will select everything from the table except rows where the value in col1 is in any other row in col2 in the same table. It sounds like that's what you're looking for, hopefully you can adapt that to your database.
i tried what u gave me but no result, i implemented it like this
$query = "SELECT * FROM bids WHERE bidder NOT IN (SELECT tagged FROM bids)";
$params = array();
$db->query($query, $params);$i = 0;
while ($row = $db->fetch())
{
$template->assign_block_vars('tag_bidder', array(
'BGCOLOUR' => (!($i % 2)) ? '' : 'class="alt-row"',
'ID' => $row['bidder'],
'TAGGED' => $row['tagged']
));
$i++;
} -
8 minutes ago, dsonesuk said:
Its no good createing a duplicate topic, it will be deleted. You have mysqli database connection, you have sql query to give you what you want, you just need to integrate into the mysqli method to retrieve those results.
and yet am not getting the issue solved, i dropped down d full code am using for the form i even asked u to assist implement it atleast this way i know what am doing
-
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');
-
19 minutes ago, dsonesuk said:
This is the same original code you have been showing from the start? WHERE is the code where you integrated OUR code, but error comes up? The idea is to learn not get us to do all the work for you.
oh i see, and ur code are pdo am using mysql i believe thats y am seeing d error
-
40 minutes ago, dsonesuk said:
WHICH is exactly what I have giving you, sql version, and sql with php filtering version, all you have to edit it to work with your existing code method.
heres the ccomplete code
$query = "SELECT b.auction, b.buyer, 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++; }
am a newbie am still figuring out php thats d code i use for the form plz intergrate for me thanksm, sorry for the stress
-
Just now, dsonesuk said:
My code uses pdo prepared method, if you just copy and paste it probably won't work, but I can't tell because I am not procession of the power of mind reading or the force.
mind reading as in? some one drop this code
buyer != tagged that works if the value are on the same line eg
bidder tagged
2 1
4 4
8 6
with the 4 like it works isnt there anycode that can check even its on the last row? and like i said b4 am a newbie so given me a code will simply means copy n pasting with little edit
-
26 minutes ago, dsonesuk said:
I get what you want! I GOT it from your first opening post in topic. Your other explanations describe a mixture of both of what you want and the opposite, that is why its difficult for other to give correct solution.
The code I have supplied, with sql statement, is what you need to use for accessing required records using your method of accessing database records. The if condition compares values in array with values looped through the foreach loop values.
but it showing error or am i implementing it wrong? can u implement for me in my code i added above? so i know what am doing wrong
-
1 hour ago, dsonesuk said:
NO!
i just need it not to display if found any where in both buyer and tagged
means same row in 'buyer' and 'tagged' different to
I just need it not to display if found any where in a 'buyer' column rows and all or same 'tagged' columns rows.
ok this is what am saying and want
columns
buyer tagged
5 3
3 2
6 0
the 3 is in both so i dont want it to display.
someone drop this code which i used buyer != tagged
it only work if the row looks like this
buyer tagged
3 3
5 2
6 0
the 3 are on the same row then it will work, but i only altered that manually to check it out not what i want, also i tried ur codes again same error can it b a where not in code of some sort or something
-
39 minutes ago, dsonesuk said:
You could filter out using PHP by creating array of duplicate values, then use !in_array() do not process
$sqlDup = "SELECT buyer FROM bids WHERE buyer IN ( SELECT DISTINCT tagged FROM bids)"; $stmtDup = $pdo->prepare($sqlDup); $stmtDup->execute(); $DuplicatesInTaggedRows = []; while ($row = $stmtDup->fetchObject()) { $DuplicatesInTaggedRows[] = $row->buyer; }
Then use code similar to
while ($row = $stmt->fetchObject()) { if (!in_array($row->buyer, $DuplicatesInTaggedRows)) { echo "<li>{$row->buyer}</li>"; } }
hi thanks for taking d time to write i just added the code n am getting error null n long error msgs
-
i just need it not to display if found any where in both buyer and tagged
-
8 hours ago, justsomeguy said:
If this is a row with the same value in 2 columns, you can just use what Ingolme said, you don't need a subquery for that. If they are in different rows then you need a join or subquery.
bidder as it row tagged as it row
-
i don't understand what am doing wrong here plz some one help with implementing it in this code of mine i tried the codes alone but didnt return a result.
note: the data are not on the same line or roll, they are just in the same columns (bidder and tagged)
$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++; }
updating a user row, need help.
in PHP
Posted
arr jeez sorry wrong code tot i copied it right so sorry heres d code i use
// tagged
$query = "SELECT b.*, u.nick FROM " . $DBPrefix . "bids b
LEFT JOIN " . $DBPrefix . "users u ON (u.id = b.bidder)
LEFT JOIN " . $DBPrefix . "bids_tagged bt ON (bt.id = b.bidder)
WHERE b.bidder NOT IN ('b.tagged') and b.tagged IN ('bt.bidder') and b.auction = :auc_id ";
$params = array();
$params[] = array(':auc_id', $id, 'int');
$db->query($query, $params);
if ($bidder = $tagged)
{
// Also insert bids_tagged table
$query = "INSERT INTO " . $DBPrefix . "bids_tagged VALUES (NULL, :auc_id, :bidder_id, :bid, :time, :qty, :willwin, :tagged, :balance)";
$params = array();
$params[] = array(':bid', $bid, 'float');
$params[] = array(':auc_id', $id, 'int');
$params[] = array(':bidder_id', $bidder_id, 'int');
$params[] = array(':time', $NOW, 'int');
$params[] = array(':qty', $qty, 'int');
$params[] = array(':willwin', $willwin, 'str');
$params[] = array(':tagged', $tagged, 'int');
$params[] = array(':balance', $balance, 'int');
$db->query($query, $params);
// update bids
$query = "UPDATE " . $DBPrefix . "bids SET bidder = (tagged)";
$params[] = array(':auc_id', $id, 'int');
$db->direct_query($query);
}
$i = 0;
while ($row = $db->fetch())
{
$template->assign_block_vars('tag_bidder', array(
'ID' => $row['bidder'],
'NAME' => $row['nick'],
'WILLWIN' => $row['willwin'],
'TAGGED' => $row['tagged']
));
$i++;
}