RE: Sorting multidimensional arrays from mysql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I need your help.

I have a script that allows me to select a specific user from a mysql
database and then allow me to show the data on a specific client.

I would like to put this information into a for that I have created instead
of just displaying them on the screen.

Any Suggestions.

Keeping the faith in fatherhood

John

____________________________________________________________________________
_________________________________

PHP 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(', ', lname, fname) as
display_name from client order by lname, fname";
	$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(' ', fname, lname) as display_name
from client where id = $_POST[sel_id]";
	        $get_master_res = mysql_query($get_master);

	        $master = mysql_fetch_array($get_master_res);

	        $display_name = stripslashes($master['display_name']);
	        $student_id = stripslashes($master['student_id']);
	        $input_date = stripslashes($master['input_date']);
            $address = stripslashes($master['address']);
	        $city = stripslashes($master['city']);
            $state = stripslashes($master['state']);
	        $zip = stripslashes($master['zip']);
            $hphone = stripslashes($master['hphone']);
	        $mphone = stripslashes($master['mphone']);
            $email = stripslashes($master['email']);
	        $ctcorg = stripslashes($master['ctcorg']);
            $cmanager = stripslashes($master['cmanager']);
	        $neighborhood = stripslashes($master['neighborhood']);
            $notes = stripslashes($master['notes']);








     $display_block = "<h1>Showing Record for $display_name</h1><br>
    	                Student ID: $student_id<br>
	                    Input Date:  $input_date<br>
                        ________________________________<br>
                        Address: $address<br>
                        City: &nbsp;$city<br>
	                    State: &nbsp;$state<br>
	                    Zip Code: &nbsp;$zip<br>
	                    Home Phone: &nbsp;$hphone<br>
	                    Mobil Phone: $mphone<br>
	                    Email Address: &nbsp;$email<br>
                        ________________________________<br>
                        CTC organization: &nbsp;$ctcorg<br>
	                    Case Manager:&nbsp;$cmanager <br>
                        Neighborhoods: &nbsp;$neighborhood <br>
	                 	Intake Notes: &nbsp;$notes<br><hr><br>";

?>

<fieldset>
<legend>Enter your information in the form below:</legend>
<table width="990" height="206" border="1">
  <tr>
    <th width="467" scope="col" bgcolor="#CCFFFF"><b>Student ID:</b>
      <input type="text" name="student_id" size="15" maxlength="15" </th>
    <th width="507" scope="col" bgcolor="#CCFFFF">

Input Date: <input type="text" name="insert_date" size="15" maxlength="15"
</th><br>
<?php
//Prints something like: Monday 15th of January 2003 05:51:38 AM
echo date("l dS of F Y -- h:i:s A");//Prints something like: Monday the 15th
?>
  </tr>
  <tr>
    <td><p><i><strong>Enter Name: First,&nbsp;Last</strong></i><br>
          <input type="text" name="fname" size="15" maxlength="15">&nbsp;
          <input type="text" name="lname" size="30" maxlength="30"> &nbsp;
         <br><b>Address:</b> <br>
          <input type="text" name="address" size="40" maxlength="40">
          </p>
      <p><b>City, State, Zip Code</b> <br>
          <input type="text" name="city" size="15" maxlength="15">,
		<input type="text" name="state" size="4" maxlength="4">
        <input type="text" name="zip" size="10" maxlength="20">
  <br>
      </p></td>
    <td><b>CTC Organization:</b><br>
      <select size="1" name="ctcorg">
		<option selected>Select One</option>
		<option>Bloomfield Garfield Corp.</option>
		<option>East End Cooperative Ministry</option>
		<option>Mt. Ararat Community Activity Center</option>
		<option>Parental Stress Center</option>
		<option>YouthPlaces</option>
	</select>  <br><br>


      <b>Case Manager :</b> <br>
       <input type="text" name="cmanager" size="40" maxlength="40">

		<p><b>Neighborhood:<br>
		<select size="1" name="neighborhood">
		<option selected>Select One</option>
		<option>Bloomfield</option>
		<option>Garfield</option>
		<option>East Liberty</option>
		<option>Lincoln/Larmar</option>
		<option>Shadyside</option>
		<option>South Point Breeze</option>
		<option>North Point Breeze</option>
		</select></b></p>
	<p>&nbsp;</td>
  </tr>
  <tr>
    <td valign="top"><p><b>Home Phone:</b> <br>
          <input type="text" name="hphone" size="40" maxlength="40">
    </p>
      <p><b>Mobil Phone:</b> <br>
          <input type="text" name="mphone" size="40" maxlength="40">
      </p>
	<p><b>Email Address:</b></p>

      </p>
          <input type="text" name="email" size="40" maxlength="40">
      </p>
      </td>
    <td>
    <p><b>Notes:<br>
	</b><textarea rows="5" name="notes" cols="48"></textarea><br>
          &nbsp;</td>
  </tr>
</table>
</fieldset>


<?php

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

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux