Jump to content

HELP HElp


riddhi

Recommended Posts

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  

?>

 

 

I presume there is problem in the loop

Link to comment
https://forums.phpfreaks.com/topic/47094-help-help/
Share on other sites

Which lines are the messages indicating? Also please use the


tags when posting your code.

 

PHP is case sensitive, therefore

<?php
           echo "<td>$record['PD_DESCRIPTION']</td>";
           echo "<td>$record['PD_QTY']</td>";
           echo "<td>$record['PD_PRICE']</td>";
?>

is not the same as

<?php
           echo "<td>$record['pd_description']</td>";
           echo "<td>$record['pd_qty']</td>";
           echo "<td>$record['pd_price']</td>";
?>

 

Ken

 

Link to comment
https://forums.phpfreaks.com/topic/47094-help-help/#findComment-229692
Share on other sites

Hi Ken ,

          Since I am running the querry thus the row name must be in caps:-

 

So while using these line:-

 

<code>

                              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>";

</code>

 

I am getting the following errors:-

 

Parse error: parse error, expecting `T_STRING' or `T_VARIABLE' or

`T_NUM_STRING' in f:\program files\easyphp1-8\www\plaincart\budget.php on line 97  :'(

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/47094-help-help/#findComment-230054
Share on other sites

You should echo out the errors when debugging like so:

 

  $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") or die(mysql_error());

 

You may find something simple that you are not seeing like ' or " unescaped.

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/47094-help-help/#findComment-230079
Share on other sites

No change noticed. Actually I connected before also it was giving correctly. It stopped working properly when i was using mysql_fetch_row() after I changed to mysql_fetch_array() and added new logic it seems to run into trouble :(

              Solved it a bit after removing the else part now it works. Hope to get back with new problems

Link to comment
https://forums.phpfreaks.com/topic/47094-help-help/#findComment-230084
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.