Jump to content

Recommended Posts

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

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.