Solved

Add info from a table to an existing HTML page.

Posted on 2001-06-16
11
184 Views
Last Modified: 2008-03-06
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
0
Comment
Question by:captmatt1
11 Comments
 

Expert Comment

by:skullface
ID: 6198782
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
 
LVL 2

Accepted Solution

by:
higijj earned 75 total points
ID: 6198881
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
 
LVL 2

Expert Comment

by:higijj
ID: 6198886
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
 
LVL 2

Expert Comment

by:higijj
ID: 6198889
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
 
LVL 2

Expert Comment

by:higijj
ID: 6198890
Hope this help a little ;-)
0
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 2

Expert Comment

by:higijj
ID: 6200224
workin eh?!
0
 
LVL 2

Expert Comment

by:higijj
ID: 6212305
Hey, if it's not workin'.. let me know!

I'll give another try!
0
 
LVL 2

Expert Comment

by:higijj
ID: 6222893
????
0
 

Author Comment

by:captmatt1
ID: 6253449
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
 
LVL 2

Expert Comment

by:higijj
ID: 6253797
Sure it will ;-)
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6419173
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

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now