i want to search data from databse that how many no of bids are placed by users for that i have to first search member id from a table tbl_members than from that member id i am searching the no of bids from a table tbl_bids then from tbl_bids am also getting the product_id means on which product id the bids are placed then according to this product id amd getting the product name from tbl_products
here is my code for this process
fkdslfsd
fd sf ds fds f sd fdsgfhfgfghfgh gf hfg
fgbfd bfdb vcb vcb vcb vc b cb f gfdg fdg fdg fd gdf g fdg fd gdf
am getting everything but opnly error am getting is that the product and everything is repeating according to no of bids
please check here www.snapbid.in/make/dashboard.php
and search for damodar you will and check his details
It looks like you are outputting one row for each bid rather than each auction (which is what I think you want). I can't really post an updated version of your code as your code is a mess. Here are some pointers:
For example you could probably rewrite all your queries in your example to something like this.
SELECT
a.auction_id,
a.auction_startdate,
a.auction_enddate,
p.product_name,
p.product_price,
COUNT( DISTINCT b.bid_id) as num_bids
FROM
tbl_auctions a
INNER JOIN
tbl_products p ON a.product_id=p.product_id
INNER JOIN
tbl_bids b ON a.auction_id=b.auction_id
WHERE
b.member_id = $member_id
GROUP BY
a.auction_id
As suggested by @liquorvicar, you should be returning all this data with a single query. The only thing he was missing was the GROUP BY clause -
SELECT
a.auction_id,
a.auction_startdate,
a.auction_enddate,
p.product_name,
p.product_price,
COUNT(b.bid_id) as num_bids
FROM
tbl_auctions a
INNER JOIN
tbl_products p ON a.product_id=p.product_id
INNER JOIN
tbl_bids b ON a.auction_id=b.auction_id
WHERE
b.member_id = $member_id
GROUP BY
a.auction_id,
a.auction_startdate,
a.auction_enddate,
p.product_name,
p.product_price;