seany123 Posted June 27, 2009 Share Posted June 27, 2009 basically i have a table in my database called points_market... inside points market i have different values: market_id, Qty, Cost, Total_cost, Seller_id. all i want to do is make a if statement saying: If ($player->id is equal seller_id in any rows){ thats what im trying to do. Link to comment https://forums.phpfreaks.com/topic/163896-solved-help-with-checking-db/ Share on other sites More sharing options...
corbin Posted June 27, 2009 Share Posted June 27, 2009 SELECT 1 FROM points_market WHERE seller_id = $player->id Look into WHERE clauses of SELECT statements. Link to comment https://forums.phpfreaks.com/topic/163896-solved-help-with-checking-db/#findComment-864723 Share on other sites More sharing options...
seany123 Posted June 28, 2009 Author Share Posted June 28, 2009 i was kind of looking for something more like this... $query = $db->execute("select * from `points_market`"); $pm = $query->fetchrow(); if($player->id == $pm['seller_id']){ header('Location: points_market.php'); } but this isnt working. Link to comment https://forums.phpfreaks.com/topic/163896-solved-help-with-checking-db/#findComment-865177 Share on other sites More sharing options...
JJ2K Posted June 28, 2009 Share Posted June 28, 2009 What type of db are you using? I think you need to loop through them but i'm only familiar with mysql, maybe something like $query = $db->execute("select * from `points_market`"); $pm = $query->fetchrow(); while($pm = $query->fetchrow()){ if($player->id == $pm['seller_id']){ header('Location: points_market.php'); } } cause at the moment aren't you just retrieving one row don't you need to go through all of them to match a player id to a seller id. Also fetchrow might have to be fetcharray or something again im not familiar with what db you are using Link to comment https://forums.phpfreaks.com/topic/163896-solved-help-with-checking-db/#findComment-865189 Share on other sites More sharing options...
seany123 Posted June 28, 2009 Author Share Posted June 28, 2009 yeah i finally worked it out... what ypou wrote is pretty much what i did also.. thanks for the help. Link to comment https://forums.phpfreaks.com/topic/163896-solved-help-with-checking-db/#findComment-865222 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.