php help |
![]() |
| |
| |||
| I got a bit stuck up. Actually I in the table want to display only those product information that is below the price range.I am taking input the price after validation trying to use the following loop. It is giving error like undefined index pd_price,etc. Here is the code:- <? extract($_POST); // Extracts POST Gobal Array global $total,$price; if(isset($submit)){ err_after_submission();// Checks errors After submission if(ereg("[0-9]",$category)){ // Checks Numeric Entry by user $res=dbQuery("SELECT B.PD_THUMBNAIL,B.PD_NAME, B.PD_DESCRIPTION,B.PD_QTY,B.PD_PRICE FROM TBL_CATEGORY A, TBL_PRODUCT B WHERE A.cat_Parent_ID=$category AND A.CAT_ID=B.CAT_ID ORDER BY B.PD_PRICE"); echo "<table cellpadding='5', border='5',cellspacing='10' align='center'> <br> <b> <center> Search Result </center></b> <br><b><center> Product Details </center> </b>"; echo "<br><tr> <td> Preview </td> <td> Name </td>"; echo "<td> Description </td> <td> Quantity </td>"; echo "<td>Price</td>"; $price=$cost; //Backup data $total=0; // Contains Total Cost of the Product while ($record=mysql_fetch_array($res)){ echo "<tr>"; if($record['pd_price'] < $price) {// Display the Product if within the Price Range $total=$total + $record['pd_price']; $price=$price - $record['pd_price']; if($record["pd_thumbnail"]){ $cat_image=$record["pd_thumbnail"]; if($cat_image){ $cat_image = WEB_ROOT. 'images/product/' .$cat_image; } else{ // Image of the product not found $cat_image = WEB_ROOT. 'images/no-image-small.png'; } echo " <td width='75' align='center'> <img src='$cat_image'>"; }// End of Cost IF else { echo "<b>"; echo "<td>$record['PD_NAME']</td>"; echo "<td>$record['PD_DESCRIPTION']</td>"; echo "<td>$record['PD_QTY']</td>"; echo "<td>$record['PD_PRICE']</td>"; echo "</b>"; }// End Else echo "</tr>"; }// ENDIF }// End While echo"</table>"; }// End IF Category }// End IF Submit function err_after_submission(){ global $cost,$category; if(!ereg("[0-9]",$cost)) { // Prevents alphabet or invalid number Entry echo "<br> <center> INVALID ENTRY!!!" ." Please Enter a Number... </center>"; } if( $cost==0 || $cost < 0){ echo "<br> <center> INVALID ENTRY!!!" ." Please Enter a Valid Number... </center>"; } if(ereg("Select a Category",$category)){ // Not Even a Single Category Selected echo "<br><center>Please Select a Category</center>"; } } // End of Error Routine ?> |
![]() |
| Thread Tools | |
| Display Modes | |
| |