a webmaster learning community
     Home    Register     Search      Help      Login    
FrontPage Alternative
Sponsors

Hosting from $3.99 per month!

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions. dd

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

 

trying to post data

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> trying to post data
Page: [1]
 
frcpgh

 

Posts: 3
Joined: 4/23/2005
Status: offline

 
trying to post data - 4/28/2005 17:19:14   
Hi,

I am trying to generate a script that allows my case workers to view the data they have put in an individual client file.  I use a form to input the data, but I do not have a tool to show the case worker what data they have put in.

I have developed a script that allows me to select the individual clients name, Now I need to display the remainder of the data.

Here is my script.
 
 <?php
 //connect to database
 $conn = mysql_connect("localhost", "root", "becky") or die(mysql_error());
 mysql_select_db("testDB",$conn)  or die(mysql_error());
 if ($_POST[op] != "view")  {
 //haven't seen the selection form, so show it
 $display_block = "<h1>Select an Entry</h1>";
 //get parts of records
 $get_list = "select id, concat_ws(', ', l_name, f_name) as display_name from master_name order by l_name, f_name";
 $get_list_res = mysql_query($get_list) or die(mysql_error());
 if (mysql_num_rows($get_list_res) < 1) {
  //no records
  $display_block .= "<p><em>Sorry, no records to select!</em></p>";
 } else {
  //has records, so get results and print in a form
  $display_block .= "
  <form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
  <P><strong>Select a Record to View:</strong><br>
  <select name=\"sel_id\">
  <option value=\"\">-- Select One --</option>";
  while ($recs = mysql_fetch_array($get_list_res)) {
   $id = $recs['id'];
   $display_name = stripslashes($recs['display_name']);
   $display_block .= "<option value=\"$id\">$display_name</option>";
  }
  $display_block .= "
  </select>
  <input type=\"hidden\" name=\"op\" value=\"view\">
  <p><input type=\"submit\" name=\"submit\" value=\"View Selected Entry\"></p>
  </FORM>";
 }
 } else if ($_POST[op] == "view") {
 //check for required fields
 if ($_POST[sel_id] == "")  {
  header("Location: selentry.php");
  exit;
 }
 //get master_info
 $get_master = "select concat_ws(' ', f_name, l_name) as display_name from master_name where id = $_POST[sel_id]";
 $get_master_res = mysql_query($get_master);
 $display_name = stripslashes(mysql_result($get_master_res, 0,'display_name'));
 $display_block = "<h1>Showing Record for $display_name</h1>";
 //get all addresses
 $get_addresses = "select address, city, state, zipcode, type from address where id = $_POST[sel_id]";
 $get_addresses_res = mysql_query($get_addresses);
  if (mysql_num_rows($get_addresses_res) > 0) {
  $display_block .= "<P><strong>Addresses:</strong><br>
  <ul>";
  while ($add_info = mysql_fetch_array($get_addresses_res)) {
   $address = $add_info[address];
   $city = $add_info[city];
   $state = $add_info[state];
   $zipcode = $add_info[zipcode];
   $address_type = $add_info[type];
   $display_block .= "<li>$address $city $state $zipcode ($address_type)";
  }
  $display_block .= "</ul>";
 }
 //get all tel
 $get_tel = "select tel_number, type from telephone where master_id = $_POST[sel_id]";
 $get_tel_res = mysql_query($get_tel);
 if (mysql_num_rows($get_tel_res) > 0) {
  $display_block .= "<P><strong>Telephone:</strong><br>
  <ul>";
  while ($tel_info = mysql_fetch_array($get_tel_res)) {
   $tel_number = $tel_info[tel_number];
   $tel_type = $tel_info[type];
   $display_block .= "<li>$tel_number ($tel_type)";
  }
  $display_block .= "</ul>";
 }
 //get all fax
  $get_fax = "select fax_number, type from fax where master_id = $_POST[sel_id]";
 $get_fax_res = mysql_query($get_fax);
 if (mysql_num_rows($get_fax_res) > 0) {
  $display_block .= "<P><strong>Fax:</strong><br>
  <ul>";
  while ($fax_info = mysql_fetch_array($get_fax_res)) {
   $fax_number = $fax_info[fax_number];
   $fax_type = $fax_info[type];
   $display_block .= "<li>$fax_number ($fax_type)";
  }
  $display_block .= "</ul>";
 }
 
 //get all email
 $get_email = "select email, type from email where master_id = $_POST[sel_id]";
 $get_email_res = mysql_query($get_email);
  if (mysql_num_rows($get_email_res) > 0) {
  $display_block .= "<P><strong>Email:</strong><br>
  <ul>";
  while ($email_info = mysql_fetch_array($get_email_res)) {
   $email = $email_info[email];
   $email_type = $email_info[type];
   $display_block .= "<li>$email ($email_type)";
  }
  $display_block .= "</ul>";
 }
 //get personal note
 $get_notes = "select note from personal_notes where master_id = $_POST[sel_id]";
 $get_notes_res = mysql_query($get_notes);
 if (mysql_num_rows($get_notes_res) == 1) {
  $note = nl2br(stripslashes(mysql_result($get_notes_res,0,'note')));
  $display_block .= "<P><strong>Personal Notes:</strong><br>$note";
 }
 $display_block .= "<P align=center>
 <a href=\"addentry2.php?master_id=$_POST[sel_id]\">add info</a> ...
 <a href=\"$_SERVER[PHP_SELF]\">select another</a></p>";
 }
 ?>
 <HTML>
 <HEAD>
 <TITLE>My Records</TITLE>
 </HEAD>
 <BODY>
 <?php echo $display_block; ?>
 </BODY>
 </HTML>


< Message edited by Spooky -- 4/29/2005 14:43:21 >
Page:   [1]
OutFront Discoveries

All Forums >> Web Development >> ASP and Database >> trying to post data
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts