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 tagged
when (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 0 no 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 3
from 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++;
}
when (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
column
bidder …tagged
5… 0
no one to tag so it shows zero
so if bidder 5 finally get tagged by someone (bidder 3) it update showing the person that tag bidder 5 and it will look like this
Yes, but where is your code for the “tag” process? That is where, as well as creating the row that shows “mike” tagged “david”, it should update the “david” row to show the link to “mike”.
hi thanks for the reply below is the code i use for tagging but havent no idea how to link them
// 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);
That’s not the code to create the “tag” association - it’s not an UPDATE query. That’s just retrieving the information. The section I referred to is where the second row in your post #4 is stored, where you create a row where bidder=mike and tagged=david. That’s the bit where you also need to update bidder=david to set tagged=mike, if I understand correctly.
thanks chorn for the insight abit heavy for me to decode the article can u help with my code given above? the particular column to alter is the tagged .
i did but it doesnt respond, i even created another table hoping the update will reflect over at the new table but it only create a copy and not updating the row which i need
Yes, I think I understand what you’re trying to do, it’s just really difficult to suggest what to do without seeing the code that writes to the database table. You obviously have some code that stores a row with bidder=mike and tagged=david, you need to add some code that also updates the row where bidder=david to also write the ‘tagged’ column.
// 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);
the code above i use to write to the database, have tried including update codes but it doesnt make any changes at all.
I don’t see where you are writing to the database in this code. All I see is your retrieving data from the database. Is there more to your code that you are not showing us?
By the way, your code would be easier to read if you firmatted it. Just highlight the code and select the </> icon, that is above the edit area, or place three backticks (`) on the line before the code and three backticks on the line after. I’ve done it for you this time.