Re: Result sorting not working

From: Date: Mon, 29 Jan 2007 13:34:35 +0000
Subject: Re: Result sorting not working
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-247936@lists.php.net to get a copy of this message
Jochem, The $request_id2 and $dateTime2 variables were set further up in the code while I was testing. They are set to the $_POST['request_id] and $POST_['date_request_received'] I had just left it out to try and make the email shorter. Below is my entire page, variables set to different names to
avoid confusion.    Still having the same problem as above...search criteria
entered, but no results returned. <?php /* if the "submit" variable does not exist, the form has not been submitted - display initial page */ if (!isset($_POST['submit'])) { ?> <form name="submitForm" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table align="center" width="780" cellpadding="2" cellspacing="2" border="0"> <tr> <td width="185" align="right"><span class="smallbold">Request Id:</span></td> <td width="128" class="tblcell"><input type="Text" value="" name="request_id" size="8" maxlength=""></td> <td width="187" align="right"><span class="smallbold">Date Entered:</span></td> <td width="254" class="tblcell"><input type="Text" value="" name="date_entered" size="15" maxlength=""></td> </tr> <tr> <td width="185" height="27" align="right"><span class="smallbold">Status:</span></td> <td width="128" class="tblcell"><input type="Text" value="" name="status" size="8" maxlength=""></td> <td width="187" align="right"><span class="smallbold">Request Type:</span></td> <td width="254" class="tblcell"><input type="Text" value="" name="request_type" size="15" maxlength=""></td> </tr> </table> <FORM ACTION="a href="javascript:clearForm()" METHOD="POST" name="logoutform"> <table align="center" border="0" cellpadding="0" cellspacing="0" width="780"> <tr> <td colspan="2"> <input type="submit" name="submit" value="Search">&nbsp; <input type="submit" name="reset" value="Reset"> </td> </tr> </table> <table align="center" border="0" cellpadding="0" cellspacing="0" width="780"> <tr><td>&nbsp;</td></tr> <tr> <td height="13" align="center" class="tblhead"><div align="center"><strong>Process
       Payments </strong></div></td>
</tr> <tr> <td colspan="6"><hr color="#006600" /></td> </tr> </table> <table align="center" border="0" cellpadding="0" cellspacing="0" width="780"> <tr> <td width="88" height="13" align="center" class="tblhead"><div align="center">Request
       ID </div></td>
<td width="224" height="13" align="center" class="tblhead"><div align="center">Date/Time
       Entered </div></td>
<td width="156" height="13" align="center" class="tblhead"><div align="center">Status</div></td> <td width="156" height="13" align="center" class="tblhead"><div align="center">Request Type </div></td> <td width="156" height="13" align="center" class="tblhead"><div align="center">Last Processed By</div></td> </tr> </table> <?php $database = "database"; $host = "server"; $user = "username"; $pass = "pasword"; // Connect to the datbase $connection = mssql_connect($host, $user, $pass) or die ('server connection failed'); $database = mssql_select_db("$database", $connection) or die ('DB selection failed'); // Query the table and load all of the records into an array. $sql = "SELECT
    child_support_payment_request.credit_card_id,
credit_card_payment_request.credit_card_id, date_request_received FROM child_support_payment_request,
        credit_card_payment_request
     WHERE child_support_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id"; $result = mssql_query($sql) or die(mssql_error()); echo "<table width='780' border='1' align='center' cellpadding='2' cellspacing='2' bordercolor='#000000'>"; while ($row = mssql_fetch_array($result)) { $id = $row['credit_card_id']; $dateTime = $row['date_request_received']; echo "<tr>"; echo "<td width='88' height='13' align='center' class='tblcell'><div align='center'>$id</div></td>"; echo "<td width='224' height='13' align='center' class='tblcell'><div align='center'>$dateTime</div></td>"; echo "<td width='156' height='13' align='center' class='tblcell'><div align='center'>Open</div></td>"; echo "<td width='156' height='13' align='center' class='tblcell'><div align='center'>Payment Type</div></td>"; echo "<td width='156' height='13' align='center' class='tblcell'><div align='center'>Last Processed By</div></td>"; echo "</tr>"; } echo "</table>"; } else { /* if the "submit" variable exists, the form has been submitted - look for and process form data */ // display result $request_id = $_POST['request_id']; $date_entered = $_POST['date_entered']; $status = $_POST['status']; $request_type = $_POST['request_type']; ?> <form name="submitForm" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <table align="center" width="780" cellpadding="2" cellspacing="2" border="0"> <tr> <td width="185" align="right"><span class="smallbold">Request Id:</span></td> <td width="128" class="tblcell"><input type="Text" value="<?php echo $request_id; ?>" name="request_id" size="8" maxlength=""></td> <td width="187" align="right"><span class="smallbold">Date Entered:</span></td> <td width="254" class="tblcell"><input type="Text" value="<?php echo $date_entered; ?>" name="date_entered" size="15" maxlength=""></td> </tr> <tr> <td width="185" height="27" align="right"><span class="smallbold">Status:</span></td> <td width="128" class="tblcell"><input type="Text" value="<?php echo $status; ?>" name="status" size="8" maxlength=""></td> <td width="187" align="right"><span class="smallbold">Request Type:</span></td> <td width="254" class="tblcell"><input type="Text" value="<?php echo $request_type; ?>" name="request_type" size="15" maxlength=""></td> </tr> </table> <FORM ACTION="a href="javascript:clearForm()" METHOD="POST" name="logoutform"> <table align="center" border="0" cellpadding="0" cellspacing="0" width="780"> <tr> <td colspan="2"> <input type="submit" name="submit" value="Search">&nbsp; <input type="submit" name="reset" value="Reset"> </td> </tr> </table> <table align="center" border="0" cellpadding="0" cellspacing="0" width="780"> <tr><td>&nbsp;</td></tr> <tr> <td height="13" align="center" class="tblhead"><div align="center"><strong>Process
       Payments </strong></div></td>
</tr> <tr> <td colspan="6"><hr color="#006600" /></td> </tr> </table> <table align="center" border="0" cellpadding="0" cellspacing="0" width="780"> <tr> <td width="88" height="13" align="center" class="tblhead"><div align="center">Request
       ID </div></td>
<td width="224" height="13" align="center" class="tblhead"><div align="center">Date/Time
       Entered </div></td>
<td width="156" height="13" align="center" class="tblhead"><div align="center">Status</div></td> <td width="156" height="13" align="center" class="tblhead"><div align="center">Request Type </div></td> <td width="156" height="13" align="center" class="tblhead"><div align="center">Last Processed By</div></td> </tr> </table> <?php $database = "database"; $host = "server"; $user = "username"; $pass = "password"; // Connect to the datbase $connection = mssql_connect($host, $user, $pass) or die ('server connection failed'); $database = mssql_select_db("$database", $connection) or die ('DB selection failed'); // Query the table and load all of the records into an array. $query = "SELECT
    child_support_payment_request.credit_card_id,
credit_card_payment_request.credit_card_id, credit_card_payment_request.date_request_received FROM child_support_payment_request,
        credit_card_payment_request
     WHERE child_support_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id"; if ($request_id !== '') { $query.=" AND credit_card_payment_request.credit_card_id = $request_id"; } if ($dateTime !== '') { $query.=" AND credit_card_payment_request.date_request_received = $dateTime"; } $res = mssql_query($query) or die(mssql_error()); echo "<table width='780' border='1' align='center' cellpadding='2' cellspacing='2' bordercolor='#000000'>"; while ($rows = mssql_fetch_array($res)) { $res_id = $rows['credit_card_id']; $res_dateTime = $rows['date_request_received']; echo "<tr>"; echo "<td width='88' height='13' align='center' class='tblcell'><div align='center'>$res_id</div></td>"; echo "<td width='224' height='13' align='center' class='tblcell'><div align='center'>$res_dateTime</div></td>"; echo "<td width='156' height='13' align='center' class='tblcell'><div align='center'>Open</div></td>"; echo "<td width='156' height='13' align='center' class='tblcell'><div align='center'>Payment Type</div></td>"; echo "<td width='156' height='13' align='center' class='tblcell'><div align='center'>Last Processed By</div></td>"; echo "</tr>"; } echo "</table>"; ?> <?php } ?> </body> </html> On 1/27/07, Jochem Maas <jochem@iamjochem.com> wrote:
Dan Shirah wrote: I have a search page that displays all active records in my application, but for some reason, I can not get it to display based on a specific input. For instance, I have records with id's 2, 3, 4, 5 etc... In my search form, the default view shows all records, and my form variable lets you put in different search criteria. If I do a search by id and put in "2" as the search condition, my results keep coming back blank. It does not matter which parameter or value I put in, it still returns blank. Any ideas? you don't bother to read your own code thoroughly? see below: <?php $connection = mssql_connect($host, $user, $pass) or die ('server connection failed'); $database = mssql_select_db("$database", $connection) or die ('DB selection failed'); // Query the table and load all of the records into an array. $query = "SELECT
    child_support_payment_request.credit_card_id,
credit_card_payment_request.credit_card_id, credit_card_payment_request.date_request_received FROM child_support_payment_request,
        credit_card_payment_request
     WHERE child_support_payment_request.credit_card_id =
credit_card_payment_request.credit_card_id"; if ($request_id !== '') { $query.=" AND credit_card_payment_request.credit_card_id = $request_id2"; $request_id AND $request_id2 ?? } if ($dateTime !== '') { $query.=" AND credit_card_payment_request.date_request_received = $dateTime2"; $dateTime AND $dateTime2 ?? ... ecified in a seperate chunk of php code, but are still included on the same page as the code below. Am I right in assuming that any variable set on the same page can be carried into different php blocks on the same page? Example: <?php $id = $_POST['request_id'] ?> <?php echo "<table>"; echo "<td>"' echo $id; echo "</td>"; echo "</table>"; ?> That would be valid, correct? yes.


« previous php.general (#247936) next »