teitanerim Posted December 14, 2006 Share Posted December 14, 2006 Hi, i'm trying to see if the current userid of the user matches any userid in the table... but i cannot get the query correct. here's what I have $userid = $my->id; //needed to get current userid $have_listing = "SELECT `userid`=$uid FROM `agent_list`"; mysql_query($have_listing); if($uid == $userid) { echo "You already have a listing, would you like to edit?"; } else { ... can anyone help? thanks in advance!}Thanks,Daniel Link to comment https://forums.phpfreaks.com/topic/30653-search-table-column-against-a-variable-help/ Share on other sites More sharing options...
zq29 Posted December 14, 2006 Share Posted December 14, 2006 Your query is structured incorrectly, it should read:[code]SELECT `userid`FROM `agent_list` WHERE `userid`='$uid'[/code]Although, I'm not sure if your code will do what you expect anyway, try this...[code]<?php$userid = $my->id;$count = mysql_result(mysql_query("SELECT COUNT(*) FROM `agent_list` WHERE `user_id`='$userid'"),0);echo ($count > 0) ? "You have a listing" : "You do not have a listing";?>[/code] Link to comment https://forums.phpfreaks.com/topic/30653-search-table-column-against-a-variable-help/#findComment-141290 Share on other sites More sharing options...
teitanerim Posted December 14, 2006 Author Share Posted December 14, 2006 thanks buddy i'll try this out asap Link to comment https://forums.phpfreaks.com/topic/30653-search-table-column-against-a-variable-help/#findComment-141296 Share on other sites More sharing options...
teitanerim Posted December 14, 2006 Author Share Posted December 14, 2006 thanks buddy, worked like a charm :) Link to comment https://forums.phpfreaks.com/topic/30653-search-table-column-against-a-variable-help/#findComment-141337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.