Hi ..........

I attached screen shot with this thread. is this possible for calculating these two values and display the same page. This values retrieve from database.

Recommended Answers

All 14 Replies

How we avoid this error. If I enter something empty field it displays following error.

Notice: Undefined index: ploca in C:\wamp\www\data\accep.php on line 20
Notice: Undefined index: psco in C:\wamp\www\data\accep.php on line 19

Yes it certainly is. If you post your code I'd be happy to help.
Simply posting error messages and screenshots wont get you any help on this forum.

:)

Try to post your codes nobody can understand your error

Member Avatar for diafol

Yuk! Nobody's gonna open a Word document! Dirty, nasty little things. If you need to show a screenshot, use an image. BUT, code is mandatory.

Add Item.php

<body>
<script type="text/javascript">
function showUser(str)
{
if (str=="")
  {
  document.getElementById("txtHint").innerHTML="";
  return;
  }
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","getite.php?q="+str,true);
xmlhttp.send();
}
</script>
</head>
<body>
<form action="getite.php">
<h3><a href="getitem.php">Add Item</a></h3>
<h3><a href="http://localhost/da/logi.php">Home</a></h3><br/>
<?php
error_reporting(0);
    mysql_connect("localhost","root","");
    mysql_select_db("menus") or die(mysql_error());

$query="SELECT DISTINCT main FROM smenu";


$result = mysql_query ($query);
echo "<select name='sers' onchange='showUser(this.value)'>";
// printing the list box select command

while($nt=mysql_fetch_array($result)){
echo "<option value='$nt[main]'>$nt[main]</option>";



}

echo "</select>";


?> 
<div id="txtHint"><b>Items info will be listed here.</b></div>
</form>
</body>
</html>

getite.php

<body>
<?php
$q=$_GET["q"];
echo "$q";
error_reporting(0);
    mysql_connect("localhost","root","");
    mysql_select_db("menus") or die(mysql_error());


    $sql="SELECT * FROM smenu WHERE main = '".$q."'";

$result = mysql_query($sql);


         mysql_close($con);
         echo "<table width=900 border=1>";
        echo "<tr bgcolor=#ccccc>";
        echo  "<th width=80 scope=col>id</th>";
        echo " <th width=100 height=34 scope=col>Item</th>";
        echo "<th width=500 scope=col><div align=center>Description</div></th>";
        echo "<th width=300 scope=col><div align=center>Category</div></th>";
        echo "<th width=94 scope=col>Rate</th>";
        echo "<th width=94 scope=col>Order Item</th>";
        echo "</tr>";

         while($row=mysql_fetch_array($result))
         {
         echo "<tr><td align='center'>";
         echo $row['id'];
         echo "</td><td align='center'>";
         echo $row['itemm']; 
         echo "</td><td align='left'>";
         $chec=$row['descrip'];
         if ($chec == ' ' or $chec == Null)

echo 'NILL';

else
         echo $row['descrip'];
         echo "</td><td align='center'>";

$check = $row['Category'];

if ($check == ' ' or $check == Null)

echo 'NILL';

else
         echo $row['Category'];
         echo "</td><td align='center'>";
         echo $row['Rate'];
         echo "</td><td align='center'>";
echo "<a href=detail.php?id=".$row['id'].">Order</a>";
          echo "</td></tr>";
         }
         echo "</table>";

            ?>

</body>
</html>

detail.php

 <form id="form1" name="form1" method="post" action="accep.php">
    <?php

    mysql_connect("localhost","root","");
    mysql_select_db("menus") or die(mysql_error());


    $idvalue=$_REQUEST['id'];




     $result=mysql_query("select * from smenu where id='$idvalue'");

         while($row=mysql_fetch_array($result))
         {

         $projectid=$row['id'];
         $projectname=$row['main'];
         $projectcat= $row['itemm'];
         $scope=$row['descrip'];
         $location=$row['Category'];
         $rate=$row['Rate'];

         }
         echo "<input type='hidden' value=".$projectid." name='pid'>";
         echo "<input type='hidden' value=".$projectname." name='pname'>";
         echo "<input type='hidden' value=".$projectcat." name='pcat'>";
         echo "<input type='hidden' value=".$scope." name='psco'>";
         echo "<input type='hidden' value=".$location." name='ploca'>";
         echo "<input type='hidden' value=".$rate." name='prate'>";



?>

                    <table width="380" height="363" border="0" align="center" cellpadding="4" cellspacing="3" >
                      <tr>
                        <td width="135">Item Id </td>
                        <td width="211"><?php  echo $projectid; ?></td>
                      </tr>
                      <tr>
                        <td>Main Item </td>
                        <td><?php  echo $projectname; ?></td>
                      </tr>
                      <tr>
                        <td>Item Name</td>
                        <td><?php  echo $projectcat; ?></td>
                      </tr>

                      <tr>
                        <td height="83">Description</td>
                        <td><?php  echo $scope; ?></td>
                      </tr>
                       <tr>
                        <td height="83">Category</td>
                        <td><?php  echo $location; ?></td>
                      </tr>
                       <tr>
                        <td>Rate</td>
                        <td><?php  echo $rate; ?></td>
                      </tr>

                      <tr>
                        <td>&nbsp;</td>
                        <td>&nbsp;</td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                        <td><input name="submit" type="submit" id="submit" value="Order this" /></td>
                      </tr>
                    </table>
                    <p>&nbsp;</p>
                    <p></p>
                  </div>
                  <p align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p>
                  </label>
<label></label>
                  <p align="center">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                  <p align="left">&nbsp;</p>
                </div>

              <h1 align="center">&nbsp;</h1>
              <p align="center">&nbsp;</p>
              </div>
                <div id="text_bottom">
                    <div id="text_bottom_left"></div>
                    <div id="text_bottom_right"></div>
                </div>
          </div>
      </div>
        <div id="content_bottom">
          <div id="content_bottom_right"></div>
      </div>
    </div>

     </form>         
</body>
</html>

accep.php

<?php


          $check=$_REQUEST['submit'];
        mysql_connect("localhost","root","");
        mysql_select_db("menus");

         $projectid=$_REQUEST['pid'];
          $projectname= $_REQUEST['pname'];
         $projectcat=  $_REQUEST['pcat'];
         $scope=$_REQUEST['psco'];
         $location=$_REQUEST['ploca'];
         $rate=$_REQUEST['prate'];



           $query="insert into orde values('$projectid','$projectname','$projectcat','$scope','$location','$rate')";
           $dbase=mysql_query($query);





?>

</body>
</html>

I posted my code. I dont know why am receiving this error. anybody know ask to me.

Notice: Undefined index: ploca in C:\wamp\www\data\accep.php on line 20
Notice: Undefined index: psco in C:\wamp\www\data\accep.php on line 19

Hi frnds,

I need to perform calculation in same field .
$sql="SELECT itemcode,itemname,quantity,price,total,remarks,SUM(total) FROM bill WHERE invoiceno = '".$q."'";

Is this query possible?anybody know say to me pls.

Member Avatar for rajarajan2017

1. Hey first come to a conclusion, which solution you want? making more confusion. In above post you showed an error and ask to resolve and now you asking a different one. whether you need solution for two or for the current post

2. For the previous post error should be happen when u having invalid variable name check whether ploca & psco is case sensitive. and one morething you should avoid $_REQUEST instead of that use $_POST in accep.php.

3. Echo the result of $locaton and $scope before using the query and check whether it shows the value

4. For the current post the query is little bit different
"Select SUM(total) from bill where invoiceno=$q"
if invoice no returns more than one row then you have single field value that is the total.

5. then use "SELECT itemcode,itemname,quantity,price,total,remarks FROM bill WHERE invoiceno = $q". (will return all the row details)

6. when printing the above values contenate a field as sum and display the output of step 4 for every record

hope this helps!

Really very very thanks of this...

Member Avatar for rajarajan2017

did you got the result as you expected?

now i try this frnd. but one more doubt. Now i clearly say.

insert into table2 , select * from table1 ( It table1 have some empty field). I try to do this Retrieve value from one table and stored into another table. I dont know how do it nu......

Member Avatar for rajarajan2017

You must read some of the guidelines and FAQ in the Daniweb Forum. Because you are asking more & more different questions in a single thread and the helpers dont know whether you got the solution for a query or not?. First of all go thru the problem that you have and listed here with prorities get cleared and then move to next one. The next new query will be started in a new thread. So please go thru the guidelines and get clear about starting threads.

$sq="Select SUM(total) from bill where invoiceno=$q";
$r=mysql_query($sq);
echo "</table>";
echo "Total";
echo $r;


I try this coding. But it shows me an output "TotalResource id #5".But the original answer is 39. any error this coding? Ask me frnd..

k frnd.

Member Avatar for rajarajan2017

Go thru the php manuals and first know how to connect database and retrieve values from there. your method of returning content is wrong! should come more statements.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.