- Pulling data from MySql into an array, then comparing the array's data to an existing variable
- <?php require_once('Connections/customer.php'); ?><?php
- if (!function_exists("GetSQLValueString")) {
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
- {
- if (PHP_VERSION < 6) {
- $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
- }
- $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
- switch ($theType) {
- case "text":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "long":
- case "int":
- $theValue = ($theValue != "") ? intval($theValue) : "NULL";
- break;
- case "double":
- $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
- break;
- case "date":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "defined":
- $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
- break;
- }
- return $theValue;
- }
- }
- $maxRows_DetailRS1 = 30;
- $pageNum_DetailRS1 = 0;
- if (isset($_GET['pageNum_DetailRS1'])) {
- $pageNum_DetailRS1 = $_GET['pageNum_DetailRS1'];
- }
- $startRow_DetailRS1 = $pageNum_DetailRS1 * $maxRows_DetailRS1;
- $colname_DetailRS1 = "-1";
- if (isset($_GET['recordID'])) {
- $colname_DetailRS1 = $_GET['recordID'];
- }
- mysql_select_db($database_customer, $customer);
- $query_DetailRS1 = sprintf("SELECT * FROM customer WHERE id = %s", GetSQLValueString ($colname_DetailRS1, "int"));
- $query_limit_DetailRS1 = sprintf("%s LIMIT %d, %d", $query_DetailRS1, $startRow_DetailRS1, $maxRows_DetailRS1);
- $DetailRS1 = mysql_query($query_limit_DetailRS1, $customer) or die(mysql_error());
- $row_DetailRS1 = mysql_fetch_assoc($DetailRS1);
- if (isset($_GET['totalRows_DetailRS1'])) {
- $totalRows_DetailRS1 = $_GET['totalRows_DetailRS1'];
- } else {
- $all_DetailRS1 = mysql_query($query_DetailRS1);
- $totalRows_DetailRS1 = mysql_num_rows($all_DetailRS1);
- }
- $totalPages_DetailRS1 = ceil($totalRows_DetailRS1/$maxRows_DetailRS1)-1;
- $query = "SELECT id, state_abbr FROM state WHERE id =".$row_DetailRS1['state']."";
- $result = mysql_select_db($database_customer, $customer)
- or die($query."<br/><br/>".mysql_error());
- ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Untitled Document</title>
- <link href="css/style.css" rel="stylesheet" type="text/css" />
- </head>
- <body>
- <table width="41%" border="0" align="center" cellpadding="2" cellspacing="5">
- <tr>
- <td width="157">Id</td>
- <td width="469"><?php echo $row_DetailRS1['id']; ?></td>
- </tr>
- <tr>
- <td>Prefix</td>
- <td><?php if($row_DetailRS1['prefix']==1) {
- echo 'Mr.';}
- else if($row_DetailRS1['prefix']==2) {
- echo 'Mrs.'; }
- else if($row_DetailRS1['prefix']==3) {
- echo 'Ms.'; }
- else if($row_DetailRS1['prefix']==4) {
- echo 'Mr. & Mrs.'; }
- else if($row_DetailRS1['prefix']==5) {
- echo 'Dr.'; }
- else if($row_DetailRS1['prefix']==6) {
- echo 'Dr. & Mrs.'; }
- else if($row_DetailRS1['prefix']==7) {
- echo 'Mr. & Dr.'; }
- else if($row_DetailRS1['prefix']==8) {
- echo 'Drs.'; }
- else if($row_DetailRS1['prefix']==9) {
- echo 'Hon.';}
- else if($row_DetailRS1['prefix']==10) {
- echo 'Hon. & Mrs.'; }
- else if($row_DetailRS1['prefix']==11) {
- echo 'Mr. & Hon.'; }
- else if($row_DetailRS1['prefix']==12) {
- echo 'Hons.'; }
- else if($row_DetailRS1['prefix']==13) {
- echo 'Rev.'; }
- else if($row_DetailRS1['prefix']==14) {
- echo 'Rev. & Mrs.'; }
- else if($row_DetailRS1['prefix']==15) {
- echo 'Atty.'; }
- else if($row_DetailRS1['prefix']==16) {
- echo 'Atty. & Mrs.'; }
- else if($row_DetailRS1['prefix']==17) {
- echo 'Mr. & Atty.'; }
- else if($row_DetailRS1['prefix']==18) {
- echo 'Attys.'; }
- else if($row_DetailRS1['prefix']==19) {
- echo 'Sen.'; }
- else if($row_DetailRS1['prefix']==20) {
- echo 'Sen & Mrs.'; }
- else if($row_DetailRS1['prefix']==21) {
- echo 'Mrs. & Sen.'; }
- else if($row_DetailRS1['prefix']==22) {
- echo 'Sens.'; }
- else if($row_DetailRS1['prefix']==23) {
- echo 'Rep.'; }
- else if($row_DetailRS1['prefix']==24) {
- echo 'Rep. & Mrs.'; }
- else if($row_DetailRS1['prefix']==25) {
- echo 'Mr. & Rep.'; }
- else if($row_DetailRS1['prefix']==26) {
- echo 'Reps.'; }
- else if($row_DetailRS1['prefix']==27) {
- echo 'Mayor'; }
- else if($row_DetailRS1['prefix']==28) {
- echo 'Admin'; }; ?></td>
- </tr>
- <tr>
- <td>Business Name</td>
- <td><?php echo $row_DetailRS1['businessName']; ?></td>
- </tr>
- <tr>
- <td>First Name</td>
- <td><?php echo $row_DetailRS1['firstName']; ?></td>
- </tr>
- <tr>
- <td>Spouse Name</td>
- <td><?php echo $row_DetailRS1['spouseName']; ?></td>
- </tr>
- <tr>
- <td>Last Name</td>
- <td><?php echo $row_DetailRS1['lastName']; ?></td>
- </tr>
- <tr>
- <td>Suffix</td>
- <td><?php if($row_DetailRS1['suffix']==1) {
- echo 'Sr.';}
- else if($row_DetailRS1['suffix']==2) {
- echo 'Jr.'; }
- else if($row_DetailRS1['suffix']==3) {
- echo 'I'; }
- else if($row_DetailRS1['suffix']==4) {
- echo 'II' ; }
- else if($row_DetailRS1['suffix']==5) {
- echo 'III'; }
- else if($row_DetailRS1['suffix']==6) {
- echo 'IV'; }
- else if($row_DetailRS1['suffix']==7) {
- echo 'V'; }
- else if($row_DetailRS1['suffix']==8) {
- echo 'Esq.'; }; ?></td>
- </tr>
- <tr>
- <td>Address</td>
- <td><?php echo $row_DetailRS1['address']; ?></td>
- </tr>
- <tr>
- <td>Address Continued</td>
- <td><?php echo $row_DetailRS1['addressCont']; ?></td>
- </tr>
- <tr>
- <td>City</td>
- <td><?php echo $row_DetailRS1['city']; ?></td>
- </tr>
- <tr>
- <td>State</td>
- <td><?php while($row = mysql_fetch_assoc($customer, $result)) {
- if($row_DetailRS1['state'] == $row) {
- echo '$row';}} ?></td>
- </tr>
- <tr>
- <td>Zip Code</td>
- <td><?php echo $row_DetailRS1['zipCode']; ?></td>
- </tr>
- <tr>
- <td>Phone Number</td>
- <td><?php echo $row_DetailRS1['phoneNum']; ?></td>
- </tr>
- <tr>
- <td>Alt. Phone Number</td>
- <td><?php echo $row_DetailRS1['altPhoneNum']; ?></td>
- </tr>
- <tr>
- <td>E-mail</td>
- <td><?php echo $row_DetailRS1['email']; ?></td>
- </tr>
- <tr>
- <td>Board Member</td>
- <td><?php echo $row_DetailRS1['boardMember']; ?></td>
- </tr>
- <tr>
- <td>Trustee</td>
- <td><?php echo $row_DetailRS1['trustee']; ?></td>
- </tr>
- <tr>
- <td>Musician</td>
- <td><?php echo $row_DetailRS1['musician']; ?></td>
- </tr>
- <tr>
- <td>Support Staff</td>
- <td><?php echo $row_DetailRS1['supportStaff']; ?></td>
- </tr>
- <tr>
- <td>Active</td>
- <td><?php echo $row_DetailRS1['active']; ?></td>
- </tr>
- <tr>
- <td>Deceased</td>
- <td><?php echo $row_DetailRS1['deceased']; ?></td>
- </tr>
- <tr>
- <td>Comments</td>
- <td><?php echo $row_DetailRS1['comments']; ?></td>
- </tr>
- </table>
- </body>
- </html><?php
- mysql_free_result($DetailRS1); ?>
- create table prefixes (
- prefix_id integer primary key,
- prefix_string varchar(20)
- );
- insert into prefixes (prefix_id, prefix_string) values (1, 'Mr.');
- insert into prefixes (prefix_id, prefix_string) values (2, 'Mrs.');
- ... etc ...
- select c.*, p.prefix_string
- from customer c, prefixes p
- where c.prefix = p.prefix_id;
- $aPrefixMap = array(
- 1 => 'Mr.',
- 2 => 'Mrs.',
- 3 => 'Ms.',
- 4 => 'Mr. & Mrs.',
- 5 => 'Dr.',
- 6 => 'Dr. & Mrs.',
- 7 => 'Mr. & Dr.',
- 8 => 'Drs.',
- 9 => 'Hon.',
- 10 => 'Hon. & Mrs.',
- 11 => 'Mr. & Hon.',
- 12 => 'Hons.',
- 13 => 'Rev.',
- 14 => 'Rev. & Mrs.',
- 15 => 'Atty.',
- 16 => 'Atty. & Mrs.',
- 17 => 'Mr. & Atty.',
- 18 => 'Attys.',
- 19 => 'Sen.',
- 20 => 'Sen & Mrs.',
- 21 => 'Mrs. & Sen.',
- 22 => 'Sens.',
- 23 => 'Rep.',
- 24 => 'Rep. & Mrs.',
- 25 => 'Mr. & Rep.',
- 26 => 'Reps.',
- 27 => 'Mayor',
- 28 => 'Admin'
- );
- $iPrefix = $row_DetailRS1['prefix'];
- if(array_key_exists($iPrefix, $aPrefixMap))
- echo $aPrefixMap[$iPrefix];
- $aRowDetailMap = array(
- 1 => 'Sr.',
- 2 => 'Jr.',
- 3 => 'I',
- 4 => 'II',
- 5 => 'III',
- 6 => 'IV',
- 7 => 'V',
- 8 => 'Esq.'
- );
- $iDetailSuffix = $row_DetailRS1['suffix'];
- if(array_key_exists($iDetailSuffix, $aRowDetailMap))
- echo $aRowDetailMap[$iDetailSuffix];