Programming › Re: Updating A Users Row by skyhighweb(op): 2:55pm On May 07, 2017 |
AntiWailer: Check your database table design structure.
This is how i will rather implement it.
I will have 2 tables.
- Bidder ===== To store details of every eligible bidder in my system
- BidderTags ==== To store all biddings and Tags.
Now each of the table will have the following fields :
== > BidderTable BidderId - A unique Id of bidders {Primary Keys} BidderName -- Full Name of the bidder ....... All other bidder related fields/data
==> BidderTagTable BidderTagId ===AutoNumber that can act as Primary Key BidderId === The Unique of the bidder in the system. a Foriegn Key to the BidderId in the Bidder Table. BidderTagged === The Id of the bidder that was tagged Active === A boolean value that indicates if this record is still ok or not ......... Other information related to the BidderTag (Dates, amount etc )
So when a bidder tags another bidder, you just drop a record in your BidderTag Table.
To know the number of tags a bidder have, run : "SELECT count(*) FROM BidderTagTable WHERE BidderTagged = 00005 AND Active = true"
You can even join the table to know the names of those who tagged him. You dont have to keep updating any row so you can keep logs for audit purpose.
Try read up on Database Normalization and understand the concept, you will not be having this kind of problem.
I hope this helps. can't i work on one table with this? dont really get what u said. |
Programming › Updating A Users Row by skyhighweb(op): 1:50pm On May 07, 2017 |
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 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
column roll for bidder 5 will look like this
bidder...............tagged 5 .......................3
complete row with bidder5 and bidder 3
bidder...............tagged 5 .......................3 3.......................5
hope u understand |
TV/Movies › Re: Terrible Movie/Series You Just Watched by skyhighweb(op): 8:39am On May 07, 2017 |
Mopricelezz: Ikr.. Emerald City is wack. Rubbish series i just did |
Programming › Re: Updating A Row by skyhighweb(op): 10:43pm On May 06, 2017 |
inage
|
Programming › Updating A Row by skyhighweb(op): 10:29pm On May 06, 2017 |
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++; }
|
Phones › Re: Gionee A1 Official Discussion Thread[HOT] by skyhighweb(m): 11:44am On May 06, 2017 |
amosunmd: i hope the phone is pocket friendly cos am on my way to pick one its 5.5 inch |
Phones › Re: Why Does Tecno Produce Substandard Phones??? by skyhighweb(m): 9:46am On May 06, 2017 |
asuustrike2009: If tecno are producing substandard phones then why are most Nigerians buying it? the so called standard phones have low sales over here haven't considered the reason behind it? cause they are packing everything in one n yet the build cant hold it |
Phones › Re: Gionee A1 Official Discussion Thread[HOT] by skyhighweb(m): 8:09am On May 06, 2017 |
donhils: But it has 64gb storage . No so bad. bro theres nothing like memory card trust me am using honor 5c its hybrid my memory card just dey ground being missed cause i need two ssim, well if am gonna b buying any pone now i must buy right two sim n memory card 5.2 inch not Techno lol |
Phones › Re: NCC Slams N4Million Fine On Innjoo For Selling Substandard Phones by skyhighweb(m): 11:41pm On May 05, 2017 |
Sphilip1: I laugh in spanish... In as much as am disappointed in Innjoo's act, i think NCC is pushing its luck.
They have made it a hobby to lay fines on companies.
My favourite president is coming for them as he come for them? |
Phones › Re: Why Does Tecno Produce Substandard Phones??? by skyhighweb(m): 11:39pm On May 05, 2017 |
emmanuelike: I saw 1gb, 8gb Room, nothing about camera was shown on d front.
So I was like since d phone d get such heavy configuration, e go get at least 5.0 camera! naaa bro doesnt work like that, d ram or gig has nothing to do with d cam, well Techno sucks either way |
Phones › Re: Why Does Tecno Produce Substandard Phones??? by skyhighweb(m): 9:22pm On May 05, 2017 |
did u check for the pone config before buying? |
Phones › Re: Gionee A1 Official Discussion Thread[HOT] by skyhighweb(m): 9:21pm On May 05, 2017 |
ans its even hybrid sim, very annoying |
TV/Movies › Re: Terrible Movie/Series You Just Watched by skyhighweb(op): 8:02pm On May 05, 2017 |
adding to it, the new triple x |
Phones › Re: Gionee A1 Official Discussion Thread[HOT] by skyhighweb(m): 5:29pm On May 05, 2017 |
why no 5.2 inch version naaaaa dont like big phones |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 3:54pm On May 05, 2017*. Modified: 4:12pm On May 05, 2017 |
have figure it out 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')
php can be something else, well unto the next coding issue |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 4:26pm On May 04, 2017 |
fleshbone: What are yoU using. sorry i meant they are aa bit similar |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 4:10pm On May 04, 2017 |
fleshbone: Its sad I couldn't help. I have no idea about PDO. am not using pdo |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 11:08am On May 04, 2017 |
no solution yet programmers |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 9:58pm On May 03, 2017*. Modified: 10:32pm On May 03, 2017 |
yorex2011: post the table structures lets fully see..
If you can $query = "SELECT b.id, b.bidder, b.tagged, b.willwin, b.auction, 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'); $db->query($query, $params); foreach ($db->fetchall() as $bidrec) { if (!isset($bidderarray[$bidrec['nick']])) { if ($user->user_data['id'] != $bidrec['bidder']) { $bidderarray[$bidrec['bidder']] = $bidrec['bidder']. ' ' . $bidderarray[$bidrec['']] = $bidrec['nick']. ' ' . $bidderarray[$bidrec['']] = $bidrec['willwin']; } } $template->assign_block_vars('tag_bidder', array( 'BGCOLOUR' => (!($i % 2)) ? '' : 'class="alt-row"', 'ID' => $bidderarray[$bidrec['bidder']], 'NAME' => $bidderarray[$bidrec['nick']], 'TAGGED' => $bidrec['tagged'] )); } table structure as below Table name is bids columns are id(int) auction(int) bidder(int) bid(double) bidwhen(varc) willwin(text) tagged(int) balance(int) thats the full code and i changed the column from buyer to bidder |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 9:05pm On May 03, 2017 |
yorex2011: skyhighweb try This SQL Statement for the first part
SELECT `buyer`, `tagged`, `auction`, `bidder`, `willwin` FROM `bids` WHERE `buyer` NOT IN (SELECT `tagged` FROM `bids`) AND `tagged` NOT IN (SELECT `buyer` FROM `bids`)
This code will return only rows that do not have values of buyers in tagged..it will also ignore rows where the duplication occured
ie 8 0 2 0 5 0 7 5 8 4 9 1
would return 8 0 2 0 8 4 9 1
Full code should then be SELECT `buyer`, `tagged` FROM `bids` WHERE `buyer` NOT IN (SELECT `tagged` FROM `bids`) AND `tagged` NOT IN (SELECT `buyer` FROM `bids`) LEFT JOIN " . $DBPrefix . "users u ON (u.id = bids.bidder) WHERE bids.auction = :auc_id ORDER BY bids.bid asc, bids.quantity DESC, bids.willwin asc
Always try to use SQL to get data, avoid using php to do stuff that SQL can do, its faster and better,
just imagine if you had 1million rows lol... hi i just implemented urs didnt work (sad face) |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 4:40pm On May 03, 2017 |
fleshbone: Am not good with object oriented aspect of mysqli.
Am sorry I don't understand some few syntax above! |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 4:36pm On May 03, 2017 |
fleshbone: Am not good with object oriented aspect of mysqli.
Am sorry I don't understand some few syntax above! hi ok i implemented where buyer != tagged, but it isnt working right it only works if the number are on the same roll eg wont work like this buyer tagged 4 5 2 0 6 4 the 4 above appears like that in the column need the code to check both columns not minding where the data is in the row but works like this i altered it just to check and it works but not the way it should(works cause i put 4 in the same roll buyer tagged 4 4 2 0 6 5 |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 3:20pm On May 03, 2017 |
fleshbone: The code should be shorter then:
$select_statement = "select * from table_name"; $result_statement = mysqli_query($db_connection, $select_statement); If(mysqli_num_rows($result_statement) > 0){ $column1 = mysqli_fetch_assoc($result_statement['column_name1']);
$column2 = mysqli_fetch_assoc($result_statement['column_name2']);
} Else{ Echo "Zero Rows in table1" }
Foreach ($column1 as $data_held){ If in_array($data_held, $column2){ Echo 'yes' //this will echo yes each time it encounter any. } Else{ Echo 'No' // for each that wasn't found. } }
Try this then. hi sorry for bugging u and i tried the above didnt getting any output i guess am doing something wrong, heres the code am using 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"', 'NAME' => $bidderarray[$bidrec['nick']], 'ID' => $bidderarray[$bidrec['id']] )); $i++; } that display users name but when they show up in both columns (buyer and tagged) i dont want them to show up on the list, so u like comparing two columns in a table. thanks |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 2:27pm On May 03, 2017 |
fleshbone: Its being a while I did php/mysqli.
Assuming u hav ur db connection setup already!
$select_statement = "select * from table_name"; $result_statement = mysqli_query($db_connection, $select_statement);
If(mysqli_num_rows($result_statement) > 0){
$all_table = mysqli_fetch_assoc($result_statement);
}
Else{ Echo "Zero Rows in table1"
}
$select_statement2 = "select * from table_name2"; $result_statement2 = mysqli_query($db_connection, $select_statement2);
If(mysqli_num_rows($result_statement2) > 0){
$all_table2 = mysqli_fetch_assoc($result_statement2);
}
Else{ Echo "Zero Rows in table2"
}
Foreach ($all_table1['column_name'] as $data_held){
If in_array($data_held, $all_table2['column_name']){ Echo 'yes' //this will echo yes each time it encounter any. } Else{ Echo 'No' // for each that wasn't found. }
}
Try this, I hope it helps, I haven't tried it though. hi thanks for the effort but am talking more of columns here not two tables but too columns |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 2:23pm On May 03, 2017 |
vicsrael: have my SQL query for that no duplicate select from multiple tables hmmm |
Programming › Re: Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 12:03pm On May 03, 2017 |
fleshbone: Fetch both table as an associative array. Then use:
For each element in array 1; Use in_array() to check if it appears in array2
Goodluck skyhighweb. plz how do i go about that? |
Programming › Already Exist Dont Display 3000 k naira for who can solve it by skyhighweb(op): 8:20am On May 03, 2017*. Modified: 8:36am On May 03, 2017 |
need a help with a PHP/MySQL issue. I have a table named bids and two column named buyer and tagged both using int.
buyer -------------- 8 5 2
tagged -------------- 5 4 1 I'm trying to detect multiple same entry number. I want if a number appears on both of the columns it shouldnt display on the menu list anymore, like the 5 above hope yo understand.
Any tip?
code below
$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'); |
Programming › Re: Already Exist Remove From List by skyhighweb(op): 12:27pm On May 02, 2017 |
roadsta: Try to be more elaborate in your questions(detailed information) if you want an elaborate answer. O.k Lets see an example :
From your initial post,i understaood that you have a list of names like "array(mike, jacob, steve, David); right? If so, all you have to do is iterate through the list, grab the selected element in the list and remove with the unset fuction passing in the key :
As an example:
$users = [mike, jacob, steve, david];
foreach($users as $key=>$val) { if ($val==david) unset($names[$key]); } print_r($users);
I hope this should help solve the problem. i sent u a mail |
Programming › Re: Already Exist Remove From List by skyhighweb(op): 6:13am On May 02, 2017 |
roadsta: In that case all you need to do is :
- grab the value from the array - then call unset($value) to remove it okay how do i do that, am not fully sure which code to edit or add |
Programming › Re: Already Exist Remove From List by skyhighweb(op): 10:42pm On May 01, 2017 |
vicsrael: Explain better than how can i make a selected data not show up in list anymore. for example on the list are steve mike dave moses if someone select dave i dont want it to show up on the list anymore. hope u understand. |
|
Programming › Re: Already Exist Remove From List by skyhighweb(op): 5:07pm On May 01, 2017 |
vicsrael: Select unique columnname from table or if u need more than one column and u don't want a particular column to repeat value use select * from table group by norepeatcolumnname not asking about that |