Jump to content

creating a custom variable after a form submission


egiblock

Recommended Posts

i'm new to php, and am stuck now..

 

what's happening is that a user is filling out a form with:

Enter the Date /Time of the Event: (eventDateTime)

Course Played: (CourseID)

Event Type: (EventTypeID)

Give the Event a Name:(customEventName)

 

when they submit, i want to create a custom name before it submits it to the database.

 

.. db connection remove, but it's working fine.......

$evtype = $_POST['EventTypeID'];

$query_AddEventGetType = "SELECT tbl_eventtype.typeID, tbl_eventtype.TypeName\n"
    . "FROM tbl_eventtype\n"
    . "WHERE tbl_eventtype.typeID = $evtype";

$AddEventGetType = mysql_query($query_EventTypeListing, $golfscoring) or die(mysql_error());	
?>

<br />
<?php
$evyear = date('Y', strtotime($_POST['eventDateTime']));
$evtitle = $_POST['customEventName'];
$fixedEventName = ($evyear . " - " . mysql_result($AddEventGetType,1) . " - " . $evtitle) ; 
?>

 

what i am ultimately trying to do is create a variable '$fixedEventName' to look like:

year - type - eventname

or 

2009 - NonLeague Play - Playing with friends.

 

 

but i am getting the actual value of the "nonleague play" of 2

so my line looks like the following:

 

2009 - 2 - Playing with friends.

 

 

 

:facewall:

 

 

Link to comment
Share on other sites

Well, where are you getting the values to create the select list (I am assuming) for the event? The select list has IDs as the values and names as the text. If you are getting those values from the database you will need to do another query first to get that value.

 

But, I have to ask, why do you want to do this? Just save a record with all the appropriate variables: year, eventID, eventname, etc. No need to concatentate the values and save that too. You can ALWAYS query the data at a later time when you need to display it and concatenate it then. You would not need to do two queries to save tha data and you can get the event name when retrieveing the data later by doign a JOIN.

 

This is completely unnecessary in my opinion. Besides, what if the event name changes at some point. Would you want the 'custom' name to have the current event name?

Link to comment
Share on other sites

actually once the event name is entered into the database, the event name won't change.

 

the reason for the event joining names is that a name could stay the same through out years, so to differentiate between years i want to put the year - type - and then the name.  plus it will show up this way when listing all of the events in a drop down box.

 

the input form is the following when filled out:

 

Event Date / Time: 
<input type="text" name="eventDateTime" value="07/30/09 12:36:58 PM"/>

Course Played:
    	<select name="CourseID">
<option value="2">Black Brook Country Club</option>
    	</select> 

Event Type:
<select name="EventTypeID">
<option value="3">Summer Tournament</option>
</select> 

Give the Event a Name:
<input name="customEventName" type="text" value="* Be Descriptive*" />


 

so the variables that i am passing to the next page is:

 

CourseID = 2

EventTypeID = 3

eventDateTime = current date and time

 

so then on the next page, the goal is to query the database and match the eventypeid (2) to the record in the database.

 

but then i am having a problem pulling the 1 variable from the database.

 

 

 

 

 

Link to comment
Share on other sites

actually i got it fixed.  i copied the code from a previous filed, and never changed the name.. 

 

$query_AddEventGetType = "SELECT tbl_eventtype.typeID, tbl_eventtype.TypeName\n"
    . "FROM tbl_eventtype\n"
    . "WHERE tbl_eventtype.typeID = $evtype";

$AddEventGetType = mysql_query($query_AddEventGetType, $golfscoring) or die(mysql_error());	
?>

<br />
<?php
$evyear = date('Y', strtotime($_POST['eventDateTime']));
$evtitle = $_POST['customEventName'];
$fixedEventName = ($evyear . " - " . mysql_result($AddEventGetType,0,1) . " - " . $evtitle) ; 
echo 'Trying to do the following:    eventName  	=	year - type - eventname<br><br>';

Link to comment
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.