[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Add info from a table to an existing HTML page.

Posted on 2001-06-16
11
Medium Priority
?
198 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 225 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Suggested Courses

649 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