Help on a simple SQL problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Below I include solutions to your problems.
* now I am in Turkey/Istanbul.. I graduated from a University here....but I
am,myself, citizen of Turkmenistan

Muhammed Mamedov
Software Engineer
YTM.com.tr

----- Original Message ----- 
From: "Ferry CS" <ferry21cs@hotmail.com>
To: "Muhammed Mamedov" <muhammed@ytm.com.tr>
Sent: Wednesday, September 10, 2003 1:56 AM
Subject: the expalination....Re: need help


> Thanks very much for your nice attention.....
> I really appreciate that..
>
> Oke, I will expalin more detail...
> For example I use mysql database
> Database = bathroom
> Table = inventory
> Field=item,date,price
>
> mysql> select * from inventory;
> item______date______price
> soap_____1/9/03_____100
> soap_____3/9/03_____500
> soap_____5/9/03_____200
> toothpaste_1/9/03____1000
>
>
> in php editor the script look like:
>
> <?
> $db_name = "bathroom";
> $table_name = "inventory";
>
> $connection = @mysql_connect("localhost", "", "") or die("Couldn't
> connect.");
>
> $db = @mysql_select_db($db_name, $connection) or die("Couldn't select
> database.");
>
> $sql = "SELECT * FROM $table_name Order by item";
>
> $result = @mysql_query($sql,$connection) or die("Couldn't execute
query.");
>
> //how to write the script here to display result on group with subtotal
and
> grand total

$tmp = mysql_query("select distinct item  from inventory",$connection); //to
select DISTINCT items: soap,toothpaste,etc..

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

    $it = $row[0]; //will contain one of soap or toothpaste,etc.

    $str = " SELECT date,price FROM inventory WHERE item='$it' ";

    $tmp2=mysql_query($str,$connection);

     echo "ITEM: ".$row[0]."<br>";  //will write "Item: soap";
     echo "DATE____________PRICE<br>";

     while($row2 = mysql_fetch_array($tmp2) ) { //here I contain all
occurencies of a certain item
            echo $row2[0]."___________".$row2[1];
      }

}


>
> //Would you help me with the script (coding)...
>
> ?>
>
> The result that I love to be display look like :
> ---------------------------------------------------------
>
> Item: soap
> ---------------------------------------------------------
> Date_____________Price
> 1/9/03____________100
> 3/9/03____________500
> 5/9/03____________200
> Total_____________800
> -----------------------------------------------------------
>
> Item: toothpaste
> ---------------------------------------------------------
> Date_____________Price
> 1/9/03___________1000
> Total____________1000
> -----------------------------------------------------------
>
> Grand Total______1800
> =============================
>
>
> Have you understand with my explaination? I hope You will
> By the way, where You from, I mean country & city?
>
> May I guess? I think You from Kazaktan or Ukrain or may be India..
> Am I right? You know, I from Indonesia, South East Asia
>
> Oke, can't wait your reply...& thanks very much
> Wish You always be happy
>
> Best Regards,
> Ferry
>
>
>
>
>
>
> ----- Original Message -----
> From: "Muhammed Mamedov" <muhammed@ytm.com.tr>
> To: "Ferry CS" <ferry21cs@hotmail.com>
> Sent: Thursday, September 11, 2003 12:28 AM
> Subject: Re: need help
>
>
> > Hi Ferry,
> >
> > I couldn't understand your problem exactly. Could you please explain it
in
> > more detail.
> > * By the way if you are asking me to help you with ODBC, want to tell
you
> > that I haven't used it before. I always use Unix based approach with
MySQL
> +
> > PHP .. actually in Windows you can also make the same stuff without
using
> > ODBC.
> >
> >
> > Sincerely,
> > M.Mamedov
> >
> > ----- Original Message -----
> > From: "Ferry CS" <ferry21cs@hotmail.com>
> > To: "Muhammed Mamedov" <mm@ytm.com.tr>
> > Sent: Wednesday, September 10, 2003 12:21 AM
> > Subject: need help
> >
> >
> > > Hi Muhammed..
> > >
> > > I knew You from php forum and I see that You great on php and a nice
one
> > > also
> > > My name Ferry from indonesia ..
> > > I have a problem to make report in php
> > >
> > > Connect with ODBC
> > > I like to display report look like
> > >
> > >
> > > ---------------------------------------------------------
> > >
> > > Item: soap
> > > ---------------------------------------------------------
> > > Date_____________Price
> > > 1/9/03____________100
> > > 3/9/03____________500
> > > 5/9/03____________200
> > > Total_____________800
> > > -----------------------------------------------------------
> > >
> > > Item: toothpaste
> > > ---------------------------------------------------------
> > > Date_____________Price
> > > 1/9/03___________1000
> > > Total____________1000
> > > -----------------------------------------------------------
> > >
> > > Grand Total______1800
> > > =============================
> > >
> > > How to make it??
> > > Would You like to help with code....please
> > > Thanks very much.....
> > >
> > > Best Regards
> > >
> >
>


Muhammed Mamedov
Software Engineer
YTM.com.tr

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux