search data from database with multiple textbox using php - php

search with multiple textbox using php
I am try this code for search with multiple textbox using php and i am using orcle database but this code is not work. and any one let me know what is the problem why this code not search with multiple text box field and also i have getting error Warning: oci_execute(): ORA-00920: invalid relational operator in
plz check .....my code..
<form action="Optr_Search.php" method="get">
<table width="500" border="0" align="center">
<tr>
<td width="203"><div align="right"><strong>Operator ID:</strong>
</div></td>
<td width="148"><input type="text" name="OPRID" /></td>
</tr>
<tr>
<td><div align="right"><strong>Operator Name:</strong></div></td>
<td><input type="text" name="OPRDEFNDESC" /></td>
</tr>
<tr>
<td><div align="right"><strong>Person ID:</strong></div></td>
<td><input type="text" name="EMPLID" /></td>
</tr>
<tr>
<td><div align="right"><strong>Email ID:</strong></div></td>
<td><input type="text" name="EMAILID" /></td>
</tr>
<tr>
<td colspan="2">
<div align ="center">
</br>
<input type="submit" align ="middle"value="Search" name ="submit" />
</div>
</td>
</tr>
</table>
</form>
<?php
$ora_conn = oci_connect('system','oracle','//localhost/XE');
if(!$ora_conn)
{
$m = oci_error();
echo $m['message'], "\n";
exit;
}
else
{
print "You are connected to the database!<br/>";
}
if(isset($_POST['submit']))
{
$optid = $_POST['OPRID'];
$optdec = $_POST['OPRDEFNDESC'];
$empid = $_POST['EMPLID'];
$empmail = $_POST['EMAILID'];
$query = "SELECT * FROM OPERATOR WHERE 1";
if(isset($optid) && $optid != '') {
$query .= " And OPRID Like'%$optid%'";
}
if(isset($optdec) && $optdec != '') {
$query .= " OR OPRDEFNDESC Like'%$optdec%'";
}
if(isset($empid) && $empid != '') {
$query .= " OR EMPLID Like '%$empid%'";
}
if(isset($empmail) && $empmail != '') {
$query .= " OR EMAILID Like '%$empmail%'";
}
$objParse = oci_parse($ora_conn,$query);
$objResult = oci_execute ($objParse, OCI_DEFAULT);
?>
<table width="500" border="1" align="center">
<tr>
<th width="98"> <div align="center">Operator ID</div></th>
<th width="98"> <div align="center">Operator Name</div></th>
<th width="98"> <div align="center">Person ID</div></th>
<th width="98"> <div align="center">Email ID</div></th>
<th width="98"> <div align="center">Edit</div></th>
</tr>
<?php
if(oci_execute($objParse,OCI_DEFAULT)){
while($objResult = oci_fetch_array($objParse, OCI_RETURN_NULLS+OCI_ASSOC))
{
?>
<tr>
<td><div align="center"><?=$objResult["OPRID"];?></div></td>
<td><?=$objResult["OPRDEFNDESC"];?></td>
<td><?=$objResult["EMPLID"];?></td>
<td><div align="center"><?=$objResult["EMAILID"];?></div></td>
<td align="center">Edit
</td>
</tr>
<?
}
?>
</table>
<?
oci_free_statement($objParse);
oci_close($ora_conn);
}
?>

You are mixing ands and ors in SQL and this is not a good idea. If you set them all to or, you will have an issue because where 1 will always be true. I would make your or conditional on the where clause not being empty.

Related

particular Data not getting inserted in a column

I am facing a unknown problem while I go insert data.Some data getting inserted in same table n same column but except one.
The following is my code.
<html>
<body>
<?php
include("index.php");
?>
<form action="addcenter.php" method="post">
<table align="center" border="9" width="600">
<tr>
<td align="center" colspan="5" bgcolor="yellow">
<h1>Add Your Center Details</h1></td>
</tr>
<tr>
<th>District Name</th>
<td><input type="text" name="district"></td>
</tr>
<tr>
<th>Phone No.</th>
<td><input type="text" name="phone"></td>
</tr>
<tr>
<th>Person's Name</th>
<td><input type="text" name="person"></td>
</tr>
<tr>
<th>Designation</th>
<td><input type="text" name="designation"></td>
</tr>
<tr>
<td align="center" colspan="5"><input type="submit" name="submit"
value="submit"></td>
</tr>
</table>
</form>
<?php
include("includes/connect.php");
if(isset($_POST['submit']))
{
$district=$_POST['district'];
$phone=$_POST['phone'];
$person=$_POST['person'];
$designation=$_POST['designation'];
if($district=='' or $phone=='' or $person=='' or $designation='')
{
echo"<script> alert('Please fill the fiels')</script> ";
exit();
}
$query="insert into centers (District,Phone,ContactPerson,Designation)
values('$district','$phone','$person','$designation') ";
if(mysql_query($query))
{
echo"<center><h1>Details Successfully added to your database</h1>
</center> ";
}
}
?>
<table width=" 900" align="center" border="3">
<tr>
<td align="center" colspan="9" bgcolor="orange"><h1>View all
Centers</h1></td>
</tr>
<tr align="center">
<th>SL No.</th>
<th>District</th>
<th>Phone No</th>
<th>Contact Person</th>
<th>Designation</th>
<th>Edit</th>
<th>Delete</th>
</tr>
<?php
$query="select * from centers";
$run=mysql_query($query);
$i=1;
while($row=(mysql_fetch_array($run)))
{
$center_id=$row['center_id'];
$district=$row['District'];
$phone=$row['Phone'];
$contact_person=$row['ContactPerson'];
$designation=$row['Designation'];
?>
<tr align="center">
<td><?php echo $i++ ;?></td>
<td><?php echo $district;?></td>
<td><?php echo $phone ;?></td>
<td><?php echo $contact_person ;?></td>
<td><?php echo $designation ;?></td>
<td>Edit
</td>
<td><input type="button" onclick="deleteme1(<?php echo $center_id ?>)"
name="delete" value="Delete"></td>
</tr>
<script language="javascript">
function deleteme1(delid1)
{
if(confirm("are u sure"))
{
window.location.href='deletecenter.php?del_id1='+delid1+'';
return true;
}
}
</script>
<?php } ?>
</table>
</body>
</html>
The problem is that when I going to insert the Contactperson,district,designation and phone no.Then only the data of Contactperson,district and phone no get inserted but not the designation..I dont know why this is happening even the coding is also right..Please help me. Thankyou
Your "if" statement is assigning '' to $designation. Use '==' for comparison.
if($district=='' or $phone=='' or $person=='' or $designation**=**'')
The if statement says, "if $district is '' or $phone is '' or $person is '' or 'I can assign nothing to $designation (which always succeeds)' - at which point you have successfully assigned '' to $designation. The if statement finishes and you insert '' into designation.

Cannot update the form to the database

hod_view.php ## // the view of apply form from database
<?php
$sql= "SELECT * FROM form WHERE id='$formID'";
$result = mysql_query($sql) or die('Cannot get ID. ' . mysql_error());
$row=mysql_fetch_array($result);
$staffID=$row['staff_id'];
$sql2= "SELECT * FROM users WHERE staff_id='$staffID'";
$result2 = mysql_query($sql2);
$row2=mysql_fetch_array($result2);
?>
<form action="viewProcess.php?action=modifyView&id=<?php echo $row['id']?>" method="post" enctype="multipart/form-data" >
<h3 class="underlineLongest">USER APPLICATION FORM </h3>
<p align="right">Reference Number : <b> <?php echo $row['ref_no']; ?> </b> </p>
<table width='100%'>
<tr>
<td colspan='2' bgcolor="#C7C7C7"> Applicant Details</td>
</tr>
<tr>
<td width='30%'>Date of Application </td>
<td width='70%'> <textColor> <?php echo $row['app_date']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>User Full Name </td>
<td width='70%'> <textColor> <?php echo $row2['name']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>Designation/Staff ID </td>
<td width='70%'> <textColor> <?php echo $staffID; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>Department/Division </td>
<td width='70%'> <textColor> <?php echo $row2['department'].'/'.$row2['division']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>Telephone Ext. No </td>
<td width='70%'> <textColor> <?php echo $row2['ext']; ?> </textColor> </td>
</tr>
<tr>
<td colspan='2' bgcolor="#C7C7C7" > Application Service Required </td>
</tr>
<tr>
<td width='30%'>Type of Application </td>
<?php
$type= $row['type'];
$result4 = mysql_query(" SELECT * FROM type WHERE type_code='$type'");
$row4=mysql_fetch_array($result4); ?>
<td width='70%'> <textColor> <?php echo $type.' - '.$row4['description']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'> Type of Facility </td>
<td width='70%'>
<textColor> <?php
$facility=explode(';',$row['facility']);
foreach($facility as $i =>$key)
{
echo $key .' - ';
$result5 = mysql_query(" SELECT * FROM facility WHERE fac_code='$key'");
while($row5=mysql_fetch_array($result5))
{
echo $row5['description'].' <br> ';
}
} ?>
</textColor> </td>
</tr>
<tr>
<td colspan='2' bgcolor="#C7C7C7" > Endorsed Status (Head of Department) </td>
</tr>
<tr>
<td width='30%'>Endorsed By </td>
<td width='70%'> <textColor> <?php echo $row['endorsed_by']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>Status </td>
<td class="alt3">
<input name="radiobutton1" type="radio" value="APPROVED" checked >Approve
<input name="radiobutton2" type="radio" value="REJECTED" >Reject
</td>
</tr>
</tr>
<tr>
<td width='30%'>Date & Time </td>
<td width='70%'> <textColor> <?php echo $row['endorsed_time']; ?> </textColor> </td>
</tr>
<tr>
<td width='30%'>Remarks </td>
<!--<td width='70%'><textarea name="endorsed_remark" id = "endorsed_remark"></textarea> </td> -->
<td><input type="text" name="endorsed_remark" id="endorsed_remark" /></td>
</tr>
</table>
<br><br>
<center><p><input class="btnSuccess" type ="submit" name="submit" value="Submit" onclick="modifyView();" >
<input class="btnEdit" type="button" name="btnCancel" value="Cancel" onclick="goBack()" > </p>
This hod_view.php is the view form that have been applied by the user. Then, the approver need to approve this form by updating the endorsed_status and endorsed_remark into the database.
Unfortunately, the form is not updated in the database.
viewProcess.php ## // the update query to database
<?php
include 'includes/initial.php';
$action = isset($_GET['action']) ? $_GET['action'] : '';
switch ($action)
{
case 'modifyView' :
break;
default :
header('Location: index.php');
}
function modifyView()
{
if(isset($_GET['id']) && $_GET['id'] > 0)
{
$formID = $_GET['id'];
}
else
{ // redirect to index.php if id is not present
header('Location: index.php');
}
echo $formID;
$sql = "UPDATE form SET endorsed_status='{$_POST['radiobutton1']}',endorsed_remark='{$_POST['endorsed_remark']}' WHERE id='$id'";
$result = mysql_query($sql) or die('Cannot update. ' . mysql_error());
if ($_POST['radiobutton2']=='REJECTED')
{
$sql = "UPDATE form SET endorsed_status='{$_POST['radiobutton2']}',endorsed_remark='{$_POST['endorsed_remark']}' WHERE id={$id} ";
$result = mysql_query($sql) or die('Cannot update. ' . mysql_error());
}
}
**This viewProcess.php is the sql query (update). Can you guys help me to make this coding correct?
Try this.
<?php
include 'includes/initial.php';
$action = isset($_POST['action']) ? $_POST['action'] : '';
switch ($action)
{
case 'modifyView' :
break;
default :
header('Location: index.php');
}
function modifyView()
{
if(isset($_POST['id']) && $_POST['id'] > 0)
{
$formID = $_POST['id'];
}
else
{ // redirect to index.php if id is not present
header('Location: index.php');
}
echo $formID;
$sql = "UPDATE form SET endorsed_status='{$_POST['radiobutton1']}',endorsed_remark='{$_POST['endorsed_remark']}' WHERE id='$id'";
$result = mysql_query($sql) or die('Cannot update. ' . mysql_error());
if ($_POST['radiobutton2']=='REJECTED')
{
$sql = "UPDATE form SET endorsed_status='{$_POST['radiobutton2']}',endorsed_remark='{$_POST['endorsed_remark']}' WHERE id={$id} ";
$result = mysql_query($sql) or die('Cannot update. ' . mysql_error());
}
}

Php calculation is posting as 0

I am having a problem with getting the calculation to post anything but 0. all other post has the correct info from the form but the calculation is not working. all the data that comes from the inputs and the calculation of the total pallets works. It is just the total price.
The whole form:
if(!checkAdmin()) {
header("Location: login.php");
exit();
}
$page_limit = 10;
// filter GET values
foreach($_GET as $key => $value) {
$get[$key] = filter($value);
}
foreach($_POST as $key => $value) {
$post[$key] = filter($value);
}
$rs_all = mysql_query("select count(*) as total_all from users") or die(mysql_error());
list($all) = mysql_fetch_row($rs_all);
?>
<?php
$rs_pickup = mysql_query("select count(*) as total_all from pickups") or die(mysql_error());
list($pickup) = mysql_fetch_row($rs_pickup);
?>
<?php
$sql="SELECT companyid, company FROM company ";
$result=mysql_query($sql) or die(mysql_error());
$options="";
while ($row=mysql_fetch_array($result)) {
$id=$row["companyid"];
$thing=$row["company"];
$options.="<OPTION VALUE=\"$id\">".$thing.'</option>';
}
?>
<?php
?>
<?php
$err = array();
if($_POST['doPickup'] == 'Enter Pickup')
if(empty($err)) {
$companyid = $_POST['companyid'];
$sql_grd = "SELECT companyid, grade_a_pu, grade_b_pu, grade_c_pu, ns_pu, custom_pu FROM company WHERE companyid = $companyid";
$result_grd=mysql_query($sql_grd) or die(mysql_error());
while ($row_grd=mysql_fetch_array($result_grd))
{
$price_a = $row_grd["grade_a_pu"];
$price_b = $row_grd["grade_b_pu"];
$price_c = $row_grd["grade_c_pu"];
$price_ns = $row_grd["ns_pu"];
$price_cus = $row_grd["custom_pu"];
}
$total_credit = (($_POST['grade_a_pal']*$price_a)+($_POST['grade_b_pal']*$price_b)+($_POST['grade_c_pal']*$price_c)+($_POST['ns_pal']*$price_ns)+($_POST['cus_pal']*$price_cus));
$sql_insert = "INSERT into `pickups`
(`companyid`,`pu_date`,`trail_num`,`grade_a_pal`,`grade_b_pal`,`grade_c_pal`,`ns_pal`,`cus_pal`,`pal_pu`,`credit`)
VALUES ('$_POST[companyid]','$_POST[pu_date]','$_POST[trail_num]','$_POST[grade_a_pal]','$_POST[grade_b_pal]','$_POST[grade_c_pal]','$_POST[ns_pal]','$_POST[cus_pal]','$_POST[pal_pu]','$total_credit')";
mysql_query($sql_insert,$link) or die("Insertion Failed:" . mysql_error());
}
?>
<html>
<head>
<title>USMI Pallets, Inc. :: Pickup Entry Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="styles.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"> </script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$("#datepicker").datepicker({
dateFormat: 'yy-mm-dd',
changeMonth: true,
changeYear: true
});
});
</script>
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php include("header.php"); ?>
<tr>
<td colspan="3" height="23" valign="top" style="background-color:#A42914 ">
</td>
</tr>
<?php include("admin_menu.php"); ?>
<td width="800" valign="top" style="padding: 10px;">
<table width="100%" border="0" cellpadding="5" cellspacing="0" class="myaccount">
<tr>
<td>Total Pickups: <?php echo $pickup;?></td>
</tr>
</table>
<p><?php
if(!empty($msg)) {
echo $msg[0];
}
?></p>
<table width="80%" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color: #E4F8FA;padding: 2px 5px;border: 1px solid #CAE4FF;" >
<tr>
<td><form name="form1" method="get" action="pickup_ent.php">
<p align="center">Search Account:
<SELECT NAME=companyid id="q">
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT>
<br>
</p>
<p align="center">
<input name="doSearch" type="submit" id="doSearch2" value="Search">
</p>
</form></td>
</tr>
</table>
<p>
<?php if ($get['doSearch'] == 'Search') {
$sql = "SELECT * FROM pickups WHERE companyid = '$_REQUEST[companyid]' ORDER BY pu_date DESC";
$rs_total = mysql_query($sql) or die(mysql_error());
$total = mysql_num_rows($rs_total);
if (!isset($_GET['page']) )
{ $start=0; } else
{ $start = ($_GET['page'] - 1) * $page_limit; }
$rs_results = mysql_query($sql . " limit $start,$page_limit") or die(mysql_error());
$total_pages = ceil($total/$page_limit);
?>
<?php
// outputting the pages
if ($total > $page_limit)
{
echo "<div><strong>Pages:</strong> ";
$i = 0;
while ($i < $page_limit)
{
$page_no = $i+1;
$qstr = ereg_replace("&page=[0-9]+","",$_SERVER['QUERY_STRING']);
echo "$page_no ";
$i++;
}
echo "</div>";
} ?>
<form name "searchform" action="pickup_ent.php" method="post">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0">
<tr bgcolor="#E6F3F9">
<td class="myheader">ID</td>
<td class="myheader">Company #</td>
<td class="myheader">Date</td>
<td class="myheader">Trailer Number</td>
<td class="myheader">Grade A</td>
<td class="myheader">Grade B</td>
<td class="myheader">Grade C</td>
<td class="myheader">Non-Std</td>
<td class="myheader">Custom</td>
<td class="myheader">Total Pickup</td>
<td class="myheader">Total Credit</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<?php while ($rrows = mysql_fetch_array($rs_results)) {?>
<tr>
<td> <div align="center"><?php echo $rrows['pickup_id']; ?></div> </td>
<td> <div align="center"><?php echo $rrows['companyid']; ?></div></td>
<td> <div align="center"><?php echo $rrows['pu_date']; ?></div></td>
<td> <div align="center"><?php echo $rrows['trail_num'];?></div></td>
<td> <div align="center"><?php echo $rrows['grade_a_pal'];?></div></td>
<td> <div align="center"><?php echo $rrows['grade_b_pal'];?></div></td>
<td> <div align="center"><?php echo $rrows['grade_c_pal'];?></div></td>
<td> <div align="center"><?php echo $rrows['ns_pal'];?></div></td>
<td> <div align="center"><?php echo $rrows['cus_pal'];?></div></td>
<td> <div align="center"><?php echo $rrows['pal_pu'];?></div></td>
<td> <div align="center">$<?php echo $rrows['credit'];?></div></td>
<td width="10%">Edit Delete</td>
</tr>
<tr>
<?php } ?>
</table>
<p><br>
</form>
<?php } ?>
</p>
<h2><font color="#FF0000">Pickup Entry
Page</font></h2>
<p> </p>
<form name "pickupform" action="pickup_ent.php" method="post">
<table width="80%" border="0" align="center" cellpadding="10" cellspacing="0" style="background-color: #E4F8FA;padding: 2px 5px;border: 1px solid #CAE4FF;" >
<tr>
<td>
Account:
<SELECT NAME=companyid>
<OPTION VALUE=0>Choose
<?=$options?>
</SELECT> </td>
</tr>
<tr>
<td>Date: <input name="pu_date" type="text" id="datepicker" /></td>
</tr>
<tr>
<td>Trailer #:<select name="trail_num" id="trail_num">
<option selected value=""></option>
<option value="1986-1">1986-1</option>
<option value="1986-2">1986-2</option>
<option value="1986-3">1986-3</option>
<option value="1986-4">1986-4</option>
<option value="1986-5">1986-5</option>
<option value="1986-6">1986-6</option>
<option value="1986-7">1986-7</option>
<option value="1986-8">1986-8</option>
<option value="1986-9">1986-9</option>
<option value="1986-10">1986-10</option>
<option value="1986-11">1986-10</option>
<option value="1986-12">1986-12</option>
</select></td>
</tr>
<tr>
<td>Grade A Pallets: <input id="grade_a_pal" name="grade_a_pal" type="text" size="8"> </td>
</tr>
<tr>
<td>Grade B Pallets: <input id="grade_b_pal" name="grade_b_pal" type="text" size="8"> </td>
</tr>
<tr>
<td>Grade C Pallets: <input id="grade_c_pal" name="grade_c_pal" type="text" size="8"> </td>
</tr>
<tr>
<td>Non-Standard Pallets: <input id="ns_pal" name="ns_pal" type="text" size="8"></td>
</tr>
<tr>
<td>Custom Pallets: <input id="cus_pal" name="cus_pal" type="text" size="8"></td>
</tr>
<tr>
<tr>
<td>Total Pallets Picked Up:
<input id="pal_pu" name="pal_pu" type="text" size="8" readonly></td>
</tr>
<td><input name="doPickup" type="submit" id="doPickup" value="Enter Pickup"></p>
</td>
</tr>
</table>
<script>
$(document).ready(function() {
//this calculates values automatically
sum();
$("#grade_a_pal, #grade_b_pal, #grade_c_pal, #cus_pal").on("keydown keyup", function() {
sum();
});
});
function sum() {
var grade_a_pal = document.getElementById('grade_a_pal').value;
var grade_b_pal = document.getElementById('grade_b_pal').value;
var grade_c_pal = document.getElementById('grade_c_pal').value;
var ns_pal = document.getElementById('ns_pal').value;
var cus_pal = document.getElementById('cus_pal').value;
var result = parseInt(grade_a_pal) + parseInt(grade_b_pal) + parseInt(grade_c_pal) + parseInt(ns_pal) + parseInt(cus_pal);
if (!isNaN(result)) {
document.getElementById('pal_pu').value = result;
}
}
</script>
</form>
<p> </p>
<p> </p>
<p> </p></td>
<td width="12%"> </td>
</tr>
<tr>
<td colspan="3" height="43" valign="top" style="background-color:#A42914 ">
<table width="766" style="height:100% " border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" class="myfooter">
<div style="margin:12px 0px 0px 31px; ">
© 2012 USMI Pallets, Inc. All rights reserved
</div>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
It appears you are using $_post (lower case) instead of $_POST (uppercase) for your pallets vars.
Try outputting a print_r($_POST) to see what you are getting in your $_POST array. It could just be you are referencing the wrong vars.

simple members inquiry that can be access for members only

I'm creating a membership page
My login page seems to be okay when entering a account number it display the certain details about the account.
Now I created a two relational tables, I need to add this to the member page? I don't know where to put the code so when I enter the account number and login the details from two relational will automatically display.
Login Code:
<p align="center"<h2>Please Sign in to Inquire your Account</h2></p>
<?php
//Start session
session_start();
//Unset the variables stored in session
unset($_SESSION['SESS_MEMBER_ID']);
unset($_SESSION['SESS_FIRST_NAME']);
unset($_SESSION['SESS_LAST_NAME']);
?>
<form name="loginform" action="login_exec.php" method="post">
<table width="309" border="0" align="center" cellpadding="2" cellspacing="5">
<tr>
<td colspan="2">
<?php
if( isset($_SESSION['ERRMSG_ARR']) &&
is_array($_SESSION['ERRMSG_ARR']) && count($_SESSION['ERRMSG_ARR']) >0 ) {
echo '<ul class="err">';
foreach($_SESSION['ERRMSG_ARR'] as $msg) {
echo '<li>',$msg,'</li>';
}
echo '</ul>';
unset($_SESSION['ERRMSG_ARR']);
}
?>
</td>
</tr>
<tr>
<td width="116"><div align="right">Account Number: </div></td>
<td width="177"><input name="Account_Number" type="text" /></td>
</tr>
<tr>
<td><div align="right">Password: </div></td>
<td><input name="password" type="text" /></td>
</tr>
<tr>
<td><div align="right"></div></td>
<td><input name="" type="submit" value="Sign in" /></td>
</tr>
</table>
</form>
My Members Page Code with one table without the two relational tables:
<?php
require_once('connection.php');
$id=$_SESSION['SESS_MEMBER_ID'];
$result3 = mysql_query("SELECT * FROM member where mem_id='$id'");
while($row3 = mysql_fetch_array($result3))
{
$fname=$row3['fname'];
$lname=$row3['lname'];
$address=$row3['address'];
$contact=$row3['contact'];
$picture=$row3['picture'];
$gender=$row3['gender'];
}
?>
</h2>
</span>
<table width="597" border="0" cellpadding="0">
<tr>
<td height="26" colspan="2" class="style11"></td>
</tr>
<tr>
<td width="166" rowspan="5" class="style11"><div align="left"><img src="style/LOGO
GRAY.jpg" alt="no image found"" width="129" height="129" border="1" "<?php echo
$picture ?>/></div></td>
<td width="126" valign="top" class="style11"><div align="left">First Name:</div>
</td>
<td width="297" valign="top" class="style11"><span class="style16"><?php echo
$fname ?></span></td>
</tr>
<tr>
<td valign="top" class="style11"><div align="left">Last Name:</div></td>
<td valign="top" class="style11"><span class="style16"><?php echo $lname ?></span>
</td>
</tr>
<tr>
<td valign="top" class="style11"><div align="left">Gender:</div></td>
<td valign="top" class="style11"><span class="style16"><?php echo $gender ?></span>
</td>
</tr>
<tr>
<td valign="top" class="style11"><div align="left">Address:</div></td>
<td valign="top" class="style11"><span class="style16"><?php echo $address ?>
</span></td>
</tr>
<tr>
<td height="42" valign="top" class="style11"><div align="left">Contact No.: </div>
</td>
<td valign="top" class="style11"><span class="style16"><?php echo $contact ?>
</span></td>
</tr>
</table>
This is the code supposedly for the members page with two relational table.
My problem here I don't know how to combine the two.
<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass);
if(! $conn )
{
die('Could not connect: ' . mysql_error());
}
$memid = 3; // example
$sql = "SELECT member.*, account.* FROM member, account WHERE member.mem_id =
account.mem_id AND member.mem_id = '".$memid."' ";
mysql_select_db('databaseName');
$retval = mysql_query( $sql, $conn );
if(! $retval )
{
die('Could not get data: ' . mysql_error());
}
while($row = mysql_fetch_array($retval, MYSQL_ASSOC))
{
echo "Account Number:{$row['Account_Number']} <br> ".
"First Name: {$row['fname']} <br> ".
"Last Name: {$row['lname']} <br> ".
"Address: {$row['address']} <br> ".
"Contact: {$row['contact']} <br> ".
"Share Capital: {$row['Share_Capital']} <br> ".
"Regular Savings: {$row['Regular_Savings']} <br> ".
"Power Savings: {$row['Power_Savings']} <br> ".
"--------------------------------<br>";
}
echo "Fetched data successfully\n";
mysql_close($conn);
?>
thanks for helping.

Pulling last years data from a table

Hello I'm trying to update this scholarship application box. However when the year changed to 2013 it only displays scholarship applicant info from 2013. I'd like it to display info from 2012. I tried messing around with the date but I cant seem to figure it out. Any help would be greatly appreciated!
<?php
$appYear = date("Y").'-'.(date("Y")+1);
$sql = 'select * from sApplication where studentID = "'.$database->iPrep($_SESSION['ID']).'" AND appYear = "'.$appYear.'" LIMIT 1';
$appID = Scholarship::iFindSQL($sql);
$total = count($appID);
if ($total > 0)
{
$app = array_shift($appID);
}
else
{
$app = 0;
}
?>
<li id="item-2">
<div id="appStatus">
<h3>Application Status</h3>
<blockquote>
<?php if ($app->submitted == ('0000-00-00') || !isset($app->submitted)) { ?>
<table style="border:1px solid #000;" width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td width="50%"><strong>Scholarship<br /> 2013-2014</strong></td>
<td width="50" align="right"> <a style="font-size:16px;" href="welcome.php? app=Scholar">Apply Now</a></td>
</tr>
<tr>
<td><strong>Date Submitted</strong></td>
<td align="right"> </td>
</tr>
<tr>
<td><strong>References</strong></td>
<td align="right"> </td>
</tr>
<tr>
<td><strong>Decision</strong></td>
<td> </td>
</tr>
<tr>
<td colspan="2"><hr /></td>
</tr>
<tr>
<td><strong>Scholarship 2012-2013</strong></td>
<td> </td>
</tr>
<tr>
<td><strong>Decision</strong></td>
<td> </td>
</tr>
</table>
<?php } else { ?>
<table style="border:1px solid #000;" width="100%" border="0" cellspacing="5" cellpadding="0">
<tr>
<td width="90%"><strong>Scholarship 2013-2014</strong></td>
<td width="10%" align="right"> </td>
</tr>
<tr>
<td><strong>Date Submitted</strong></td>
<td align="right"><?=dbOutDate($app->submitted)?></td>
</tr>
<tr>
<td><strong>References</strong> </td>
<td align="right"></td>
</tr>
<tr>
<td colspan="2">
<?php
$refs = Reference::iFindSQL("Select * from reference where appID = '".$app->ID."'");?>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<?php foreach($refs as $ref) { ?>
<tr> <td> <small><?php if($ref->rType == 'Academic Reference'){ echo 'Academic/Artistic/Professional'; } else { echo 'Community Service'; } ?></small></td> <td align="right"><?=$ref->status?></td></tr>
<?php } ?>
</table>
</td>
</tr>
<tr>
<td><strong>Decision</strong></td>
<td align="right">
<?php
if ($app->complete == 'Approved') { echo 'Approved'; }
if ($app->complete == 'Declined') { echo 'Declined'; }
if ($app->complete == 'Pending') { echo 'Pending'; }
if ($app->complete == 'Incomplete') { echo 'Incomplete'; }
Remove the WHERE clause that limits the year. Use ORDER BY to sort by year, descending.
$sql = 'select * from sApplication
where studentID = "'.$database->iPrep($_SESSION['ID']).
'" ORDER BY appYear DESC LIMIT 1';

Categories