I am required by law to provide the noob disclaimer when talking anything php.
That being said what i'm trying to do has to have bee done before...I'm not reinventing the wheel..mine just dosen't seem to roll so good :mad:
What I want to be able to do.
1. Query a database using about five criteria…(name, address, ssn, birthdate.)
2.Display resultant data along with radio boxes on new page. (i.e. if I search the database for the last name smith and it returns 25 values I want to be able to pick just one and send it to the next page.)
3.On next page display chosen data set and use the breakout on html/text along with text boxes. if any info was changed have a submit that updates the individual fields in the data
I think I have the search down and it gives me a results page with radio buttons..but somehow I can't have it act on the "selected record'...actually the radio buttons are meaningles...it doesn't care if they are checked or not.
I understand exact searches work(i.e. seach for john smith, 239 ceader lane)if it returns a unique record but, searches with multiple values returned display only the last (in the whole database) data record and associate fields.
If any one can point me in the right direction (if I should be using arrays or if I have to have a check box indictor field in my database) I would appreciate it greatly.
I am trying to pass the data in 2 different ways, thats why there is a $selecrec and the broken out variables on page 2.
Posted below are the snippits of my 2 pages
TIA for any help
PAGE 1
[FONT=Arial Black]
[SIZE=2]<html>
<head>
<title>Search Form</title>
<meta name="description" content="">
<meta name="keywords" content="">
</head>
<body bgcolor="#99ccff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000"><?php
//Connect to the database
include("lib/connect.php");
!($_POST['qflag'] == "Yes") ? printform(0) : printresults();
?></form>
</body>
</html>
<?php
function printresults ()
{
global $DBUG;
if($DBUG) { print("<br><hr><br>\n"); }
$fname = $_POST['FName'];
$lname = $_POST['LName'];
$phnum = $_POST['PhoneNum'];
$CAref = $_POST['CARefNum'];
//$MercRef = $_POST['MercRefNum'];
if($DBUG) { print("[$fname][$lname][$phnum][$CAref]");
print("<br><hr><br>\n");
}
$query = "SELECT FirstName, LastName, SSN,
Address1, Address2, City,
State, Zip, TotalDue, InitialBalance
FROM account
WHERE LastName LIKE '%$lname%'
AND FirstName LIKE '%$fname%'
AND HomePhone LIKE '%$phnum%'
AND CAAccountNumber LIKE '%$CAref%'
ORDER BY LastName, FirstName, TotalDue";
$result = mysql_query($query);
$rownumber = mysql_numrows($result);
if ($rownumber == 0) {
print "Sorry, there were no records matching those criteria";
} else {
print("<hr><form name='selectrecord' method=post action='./MainScript.php'>\n");
// Print the employee names
for($i=0; $i<$rownumber; $i++)
{
$DBfname = mysql_result($result,$i,"FirstName");
$DBlname = mysql_result($result,$i, "LastName");
$DBSSN = mysql_result($result, $i, "SSN");
$DBAdd1 = mysql_result($result, $i, "Address1");
$DBAdd2 = mysql_result($result, $i, "Address2");
$DBCity = mysql_result($result, $i, "City");
$DBState = mysql_result($result, $i, "State");
$DBZip = mysql_result($result, $i, "Zip");
$DBTotalDue = mysql_result($result, $i, "TotalDue");
$DBInitalBalance = mysql_result($result, $i, "InitialBalance");
if ($DBUG) {print "<hr><br>$DBlname, $DBfname, $DBSSN, $DBAdd1, $DBadd2, $DBCity, $DBState, $DBZip, $DBTotalDue, $DBInitialBalance<br><hr>";}
print("<br><input type='radio' name='selectedrecord' value='$DBlname, $DBfname, $DBSSN, $DBAdd1, $DBAdd2, $DBCity, $DBState, $DBZip, $DBTotalDue, $DBInitialBalance'>\n"."<input type=hidden value='$DBlname' name='LN'>\n"."<input type=hidden value='$DBfname' name='FN'>\n"."<input type=hidden value='$DBSSN' name='SSN'>\n"."<input type=hidden value='$DBAdd1' name='add1'>\n"."<input type=hidden value='$DBAdd2' name='add2'>\n"."<input type=hidden value='$DBCity' name='Cy'>\n"."<input type=hidden value='$DBState' name='St'>\n"."<input type=hidden value='$DBZip' name='Z'>\n"."<input type=hidden value='$DBTotalDue' name='TD'>\n"
."$DBlname, $DBfname, $DBSSN, $DBAdd1, $DBAdd2,\n"
."$DBCity, $DBState, $DBZip, $DBTotalDue,\n"
."$DBInitialBalance<br>\n");
// ."<input type=hidden value='$DBlname' name='LN'>\n"
// ."<input type=hidden value='$DBfname' name='FN'>\n"
// ."<input type=hidden value='$DBSSN' name='SSN'>\n"
// ."<input type=hidden value='$DBAdd1' name='add1'>\n"
// ."<input type=hidden value='$DBAdd2' name='add2'>\n"
// ."<input type=hidden value='$DBCity' name='Cy'>\n"
// ."<input type=hidden value='$DBState' name='St'>\n"
// ."<input type=hidden value='$DBZip' name='Z'>\n"
// ."<input type=hidden value='$DBTotalDue' name='TD'>\n"
// ."<input type=hidden value='$DBInitalBalance' name='IB'>\n");
}
}
print("<br><input type='submit' value='Submit'>\n"
."</form>\n");
//printform(1);
}
function printform ($f)
{
print(" <form name='search' method=post>\n"
." Search by First Name<br><input name='FName'><br><br>\n"
." Search by Last Name<br><input name='LName'><br><br>\n"
." Search by Phone Number<br><input name='PhoneNum'><br><br>\n"
." Search by CA Reference Number<br><input name='CARefNum'><br><br>\n"
//." Search By Reference Number<br><input name='MercRefNum'><br><br>\n"
." <br><br><br>\n"
." <input action='./Search.php' type='submit' value='Submit Query'>\n"
." <input type='reset' value='Reset'>\n"
." <input type='hidden' name='qflag' value='Yes'>\n");
}
?>
[/SIZE]
PAGE2
[SIZE=2]
<html>
<head>
<title>Main Script</title>
</head>
<body bgcolor="#99ccff" text="#000000" link="#0000ff" vlink="#800080" alink="#ff0000">
<p align="left">
<font size="6"> Main Script</font>
<hr>
<?php
$selrec = $_POST['selectedrecord'];
$LN = $_POST['LN'];
$FN = $_POST['FN'];
$ssn = $_POST['SSN'];
$add1 = $_POST['add1'];
$add2 = $_POST['add2'];
$cy = $_POST['Cy'];
$st = $_POST['St'];
$Z = $_POST['Z'];
$TD = $_POST['TD'];
$IB = $_POST['IB'];
print("$DBlname, $DBfname, $DBSSN, $DBAdd1, $DBAdd2\n<BR>\n");
print(" $LN, $FN, $ssn, $add1, $add2, $cy, $st, $Z, $TD, $IB\n<BR>\n");
print("$selrec\n");
?>
<hr>
<a href="http://baltran">Back to Main Page </a><br>
<a href="http://baltran/Merc/v1/Search.php">Back to Search page</a>
<br>
<br><br>1.
I'm showing your name as <?php print("$FN\n,$LN\n" );?> <input name="">. Is that
Correct? <br><br>2.
<br><br>4. I'm
showing your mailing address as<?php print("$add1\n,$add2\n $cy\n, $st\n, $Z\n," );?> <input name=""> Is that correct? (Wait for response).
</body>
</html>
[/FONT]
[/SIZE]