Add info from a table to an existing HTML page.

I have a nationally approved basic boating safety course at http://boatsafe.com. I want to be able to have new students select the state in which they boat and save that as a variable.

Once I have the variable I want to query a table that has state specific information. For example lifejacket wearing requirements. Then when the student gets to the existing page which has the federal regulations dealing with lifejackets, I want to use PHP to insert the information for the students state that may be different than federal requirements.

Is this possible? Any ideas or assitance would be appreciated.

Thanks, Capt Matt
captmatt1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
higijjConnect With a Mentor Commented:
Well.. in the form that the new user fill in, there is a state field? probably a SELECT ..

So.. you could do like this:

signup.htm file:

<HTML>
<BODY>
<FORM ACTION="signup.php" METHOD="post">
<SELECT name="lifejacket">
   <OPTION VALUE="FL">Florida</OPTION>
   <OPTION VALUE="CA">California</OPTION>
   ...
</SELECT>
<BR>
<INPUT TYPE="submit" VALUE="Signup!">
</FORM>

</BODY>
</HTML>



signup.php file:

<?

// Query the table with the lifejacket requirement table
$link = mysql_connect($SQLHost, $SQLUser, $SQLPassword) OR DIE ("Unable To Connect To Database");

     mysql_select_db($SQLDatabase, $link) OR DIE("Unable To Select To Database");
     $sql = "SELECT * FROM tbl_lifejacket WHERE state='$state'";
     $result = mysql_query($sql);

     if (mysql_num_rows($result) > 0) {

        while ($row = mysql_fetch_array($result)) {

           $lifejacket_requirement = $row[your_field];

        } // end while

     } // end if

mysql_close($link);


// if $lifejacket_requirement isn't empty,
// meaning that there IS some specific REQUIREMENT,
// then print it, else, do nothing

if (!empty($lifejacket_requirement)) {
   print "$lifejacket_requirement";
} // end if


// print the rest of your page here..

?>


0
 
skullfaceCommented:
pass the state value as a HTTP_POST value.

$query= "select * form state_table where state='".$HTTP_POST["state"]."' and product_name='lifejackets'";

"Then when the student gets to the existing page which has the federal regulations
dealing with lifejackets, I want to use PHP to insert the information for the students state that may
be different than federal requirements."

cannot understand this part.. please clarify it with a detailed example.
0
 
higijjCommented:
instead of using $state, your could use HTTP_POST_VARS["state"] if you used method="post" in your <FORM> tag..

but if you used the method="get" you would have to use HTTP_GET_VARS["state"]


using $state should work fine with both method ;-)
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
higijjCommented:
btw, you can use the coded provided for signup.php in any php file where you want to use the lifejacket regulation..

and the query I provided.. is only if you have the state of your student..

so if you use the above code in another place than the signup page.. you would have to modify the query like:

$sql = "SELECT * FROM tbl_lifejacket WHERE state='$state' AND user_id='$user_id'";

where user_id field is the unique ID field in the table and $user_id is that ID for the current user..

0
 
higijjCommented:
Hope this help a little ;-)
0
 
higijjCommented:
workin eh?!
0
 
higijjCommented:
Hey, if it's not workin'.. let me know!

I'll give another try!
0
 
higijjCommented:
????
0
 
captmatt1Author Commented:
Sorry to the people in this thread I was offshore for a couple of weeks and just got back. I will try to get to your responses in the next few days and let you know how it works out. Thanks to all.

Capt Matt
0
 
higijjCommented:
Sure it will ;-)
0
 
MoondancerCommented:
It's time to clean up this topic area and that means taking care of this question. Your options at this point are:

1. Award points to the Expert who provided an answer, or who helped you most. Do this by clicking on the "Accept Comment as Answer" button that lies above and to the right of the appropriate expert's name.

2. PAQ the question because the information might be useful to others, but was not useful to you. To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

3.  Ask Community Support to help split points between participating experts.  Just comment here with details.

4.  Delete the question because it is of no value to you or to anyone else.  To use this option, you must state why the question is no longer useful to you, and the experts need to let me know if they feel that you're being unfair.

If you elect for option 2, 3 or 4, just post comment with details here and I'll take it from there.  We also request that you review any other open questions you might have and update/close them.  Display all your question history from your Member Profile to view details.

PLEASE DO NOT AWARD THE POINTS TO ME.

____________________________________________



Hi Experts:

In the event that the Asker does not respond, I would very much appreciate your opinions as to which Expert ought to receive points (if any) as a result of this question.  Likewise, you can also suggest that I PAQ or delete the question.

Experts, please do not add further "answer" information to this question.  I will be back in about one week to finalize this question.

Thank you everyone.

Moondancer :)
Community Support Moderator @ Experts Exchange

P.S.  REGARDING POINTS, Guidelines and more:  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp  
0
All Courses

From novice to tech pro — start learning today.