thecommonthread Posted February 15, 2010 Share Posted February 15, 2010 So I'm pretty new to MySQL. I have a table named "events" and two fields, one specifying the event name (event_name) and one specifying if the pricing is based on a national or local price list (local_or_national). So here is an example table I have right now: Event name Pricing My Spectacular Eventlocal A Really Great Eventnational Cool New Showlocal Show 7national Show 8national My Eventlocal My Cool Eventnational Event #2local Event #3local Event #4local Now in a form, I have a dropdown menu box that displays the event names and a button that submits the form. Now when I go to the next page, obviously I have the event title stored in a variable, so how do I use that to ask if that event is local or national? Any help would be SOOO much appreciated. Thanks, thecommonthread Link to comment https://forums.phpfreaks.com/topic/192178-mysql-question/ Share on other sites More sharing options...
Mchl Posted February 15, 2010 Share Posted February 15, 2010 SELECT local_or_national FROM events WHERE event_name = '?' Link to comment https://forums.phpfreaks.com/topic/192178-mysql-question/#findComment-1012798 Share on other sites More sharing options...
thecommonthread Posted February 15, 2010 Author Share Posted February 15, 2010 Thanks. Sorry I wasn't a little more specific, what I meant to ask was how I turn that statement in a PHP variable? Right now I have: $sql="SELECT `local_or_national` FROM `events` WHERE `event_name`='Show 8'"; $result=mysql_query($sql); And $result returns "Resource id #2" Link to comment https://forums.phpfreaks.com/topic/192178-mysql-question/#findComment-1012800 Share on other sites More sharing options...
Mchl Posted February 15, 2010 Share Posted February 15, 2010 So it's more PHP question than MySQL, isn't it? ;P $eventName = mysql_real_escape_string($_POST['eventName']) $sql="SELECT `local_or_national` FROM `events` WHERE `event_name`='$eventName'"; $result=mysql_query($sql); $row = mysql_fetch_assoc($result); echo $row['local_or_national']; Link to comment https://forums.phpfreaks.com/topic/192178-mysql-question/#findComment-1012804 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.