I have paging at the bottom.
The value of the SQL is stored in the GET string
I know you would never do it for a real database,
but this is only for a demo tomorrow.
The problem is I get the actual value of the nationalDrugCode in the GET string. I'm trying to understand this.
I should only see this value of the nationalDrugCode in the GET string when
I do a search and it is POSTED first. Then if I get some results from a search and click a 2nd page the
code should show up in the GET, but instead it is showing up from the POST
and it is messing up the pages. VEry weird.
I need the SQL WHERE vars in
in the GET. The purpose of the vars in the GET is to maintain the SQL filter on the pages. So like I said if I search on the ndc then it should be in the page GET string, but only then, and I can't figure out where the problem is. It could be a SQL problem because the value for example 12101455 also appears in the SQL when I echo the SQL statement with filters. But like I said I didn't search on that field?
So is my test wrong at the beggining? I want to capture the GET first else capture the POST.
There is only 4 fields displayed. There is only 5 fields searched on.
I have a search form.
I have a SQL with the filters.
I have the colum headers and I have the display. The only anomaly is the nationalDrugCode value in the display is the only field the user can edit on.
The others text fields in the form inputs.
I hope for some ideas what to check. THANKS,
//If there is a GET in the paging GET string then take that
//the page was clicked else take the POSTed value in the search box
if ($_GET['bu']!='' ) {
$search_bu=$_GET['bu'] ;
}else{
if ($_POST['search_bu']!=''){
$search_bu= $_POST['search_bu'];
}
}
if ($_GET['zoneid']!='' ) {
$search_zoneid=$_GET['zoneid'] ;
}else{
if ($_POST['search_zoneid']!=''){
$search_zoneid= $_POST['search_zoneid'];
}
}
if ($_GET['zonenm']!='' ) {
$search_zonenm=$_GET['zonenm'] ;
}else{
if ($_POST['search_zonenm']!=''){
$search_zonenm= $_POST['search_zonenm'];
}
}
if ($_GET['nationalDrugCode']!='' ) {
$search_nationalDrugCode=$_GET['nationalDrugCode'] ;
}else{
if ($_POST['search_nationalDrugCode']!=''){
$search_nationalDrugCode= $_POST['search_nationalDrugCode'];
}
}
if ($_GET['error_flag']!='' ) {
$search_error_flag=$_GET['error_flag'] ;
}else{
if ($_POST['search_error_flag']!=''){
$search_error_flag= $_POST['search_error_flag'];
}
}
//search box
echo "<table align='center' style='border:1px solid $CCCCCC;'>\n";
echo "<th align='right'>BU\n";
echo "<td><select name='search_bu' id='search_bu'>\n";
get_bu($search_bu);
echo "</select>\n";
echo "<tr>\n";
echo "</select>\n";
echo "<tr>\n";*/
echo "<th align='right'>Zone ID\n";
echo "<td><input type'text' name='search_zoneid' size='9' class='txt1'>\n";
echo "<tr>\n";
echo "<th align='right'>Zone Number\n";
echo "<td><input type'text' name='search_zonenm' size='9' class='txt1'>\n";
echo "<tr>\n";
echo "<th align='right'>NDC\n";
echo "<td><input type'text' name='search_nationalDrugCode' id='search_nationalDrugCode' size='15' class='txt1'>\n";
echo "<tr>\n";
echo "<th align='right'>Error Flag\n";
echo "<td><input type='radio' name='search_error_flag' class='rad1' value ='1' >Yes\n";
echo "<td><input type='radio' name ='search_error_flag' class='rad1' value='0' CHECKED>No\n";
echo "<tr>\n";
//echo "<td colspan='13' align='center'><input type='submit' name='submit1' value='Search'>\n";
echo "<td colspan='13' align='center'><input type='submit' name='submit1' value = ' Search' onclick=\" return checkscript();\">\n";
echo "</table>\n";
echo "<tr>\n";
//kills search results from displaying ALL results only requested POSTED values display
if ( !$_POST['submit1'] && $_GET['page']=='') { die();}
/
if ($search_error_flag==1) {
echo "Error Flag: ".$search_error_flag."\n";
$sql="SELECT id, bu, nationalDrugCode, error_flag ";
$sql.="FROM cart_inventory ";
if ($search_bu!=''){ $sqlWhere="WHERE bu ='$search_bu' ";}
if ($search_nationalDrugCode !='') { $sqlWhere.="AND nationalDrugCode='$search_nationalDrugCode' ";}
if (($search_zoneid !='') && ($search_zonenm!='')) { $sqlWhere.="AND zoneid ='$search_zoneid' AND zonenm='$search_zonenm' ";}
if ($search_error_flag !='' ){ $sqlWhere.="AND error_flag='$search_error_flag' "; }
$sqlOrder="ORDER BY $order ";
$sql.=$sqlWhere;
$result= mysql_query($sql);
if($_GET['nRecs']!=''){
$nRecs=$_GET['nRecs'] ;
}else{
$nRecs= mysql_num_rows($result);
}
echo "Number of Records:". $nRecs."\n";
if ($page==''){
$page=1;
$startPage=0;
}else{
$startPage=$page *25;
}
$sqlLimit="LIMIT $startPage, 25 ";
$sql.= $sqlOrder. " ". $sqlLimit;
$result=mysql_query($sql);
if ( !$result ) {die("<font color='red'>Invalid query:</font>" . mysql_error() . "<br />$sql");}
echo "<tr>\n";
echo "<table align='center' cellspacing='0' cellpadding='0' style='border-collapse:collapse;'>\n";
echo "<td style='border:solid black 1px;padding:5px;' align='center'>";
echo "<th style='border:solid black 1px;padding:5px;'>id</a>\n";
echo "<th style='border:solid black 1px;padding:5px;'>bu</a>\n";
echo "<th style='border:solid black 1px;padding:5px;'>ndc</a>\n";
echo "<th style='border:solid black 1px;padding:5px;'>error_flag</a>\n";
while ($row = mysql_fetch_assoc($result)){
//pull id on ones with errors for javascript save button
$id=$row['id'];
$bu=$row['bu'];
$nationalDrugCode=$row['nationalDrugCode'];
$error_flag=$row['error_flag'];
$cls=($cls=='gry') ? 'wht' : 'gry';
echo "<tr class='$cls'>\n";
echo "<td style='border:solid black 1px;padding:2px;'><input type='button'
value='Save' onClick='saveRecord($id'><br /><div id='txt$id' name='tag$id'><div>\n";
echo "<td style='border:solid black 1px;padding:5px;'>$id\n";
echo "<td style='border:solid black 1px;padding:5px;'>$bu\n";
//echo "<td style='border:solid black 1px;padding:5px;'><input type='text' size='30' name='nationalDrugCode' value='$nationalDrugCode'>\n";
echo "<td style='border:solid black 1px;padding:5px;'><input type='text' size='15' name='nationalDrugCode' id='nationalDrugCode' value='$nationalDrugCode'>\n";
echo "<td style='border:solid black 1px;padding:5px;'>$error_flag\n";
/* echo "<td style='border:solid black 1px;padding:2px;'><input type='button' value='Save'
onClick='saveRecord($id)'><br><div id='txt$id' name='tag$id'></div>\n";*/
}//while end
echo "</table>\n";
$noPages=$nRecs /25;
$noPages = (int) $noPages;
echo "No Pages: " . $noPages . "<br />";
for ( $p=1;$p<=$noPages;$p++ ) {
echo " <a href='$me?page=$p&error_flag=$error_flag&bu=$bu&nationalDrugCode=$nationalDrugCode&zoneid=$zoneid&zonenm=$zonenm'>$p</a>\n";
}