Re: Is this possible?
| From: | Raymond Lilleødegård | Date: | Wed, 06 Feb 2002 18:35:31 +0000 |
| Subject: | Re: Is this possible? | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-83738@lists.php.net to get a copy of this message | ||
At last! : ) Thank you very much for all help! ; )
I made it with two mysql_query()
Here are my queries if it is interesting.
$varetabell = mysql_query("SELECT varetabell.tekstbilde,
varetabell.varenavn, varetabell.varenr, varetabell.innhold, pristabell.pris
FROM varetabell, pristabell WHERE pristabell.varenr=varetabell.varenr AND
pristabell.type='footlong'",$db);
$varetab = mysql_query("SELECT varetabell.varenr, pristabell.varenr,
pristabell.pris FROM varetabell, pristabell WHERE
pristabell.varenr=varetabell.varenr AND pristabell.type='6inch'",$db);
if ($myrow = mysql_fetch_array($varetabell) AND $myro =
mysql_fetch_array($varetab)) {
echo "<TABLE border=\"0\" width=\"450\">\n";
echo " <tr>\n";
echo " <td width=\"300\" colspan=\"2\"><b><font
color=\"#000000\">Subs</font></b></td>\n";
echo " <td align=\"center\" width=\"46\"><b><font
color=\"#000000\">6\"</font></b></td>\n";
echo " <td align=\"center\" width=\"90\"><b><font
color=\"#000000\">Footlong</font></b></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td colspan=\"4\" width=\"444\"><hr
color=\"#000000\" ></td>\n";
echo " </tr>\n";
do {
printf(" <tr><form method=\"POST\" action=\"bestilling.php\"
name=\"%s\">",$myrow["varenavn"]);
printf( " <td width=\"6\"><input type=\"image\"
name=\"sub\" SRC=\"%s\"
value=\"%s\"></td>",$myrow["tekstbilde"],
$myrow["varenavn"]);
printf( " <td width=\"290\"></td>");
printf(" <td align=\"center\" width=\"46\"><font
size=\"2\"><b>%s</font></td>",$myro["pris"]);
printf( " <td align=\"center\" width=\"90\"><font
size=\"2\"><b>%s</font></td>",$myrow["pris"]);
printf(" <input type=\"hidden\" name=\"passord\"
value=\"$passord\">");
printf(" <input type=\"hidden\" name=\"fornavn\"
value=\"$fornavn\">");
printf(" <input type=\"hidden\" name=\"varenr\"
value=\"%s\">",$myrow["varenr"]);
printf("<input type=\"hidden\" name=\"sub\"
value=\"%s\"></form>",$myrow["varenavn"]);
printf(" </tr>");
printf(" <tr>");
printf(" <td
width=\"290\"><small>(%s)</small></td>",$myrow["innhold"]);
printf(" <td width=\"6\"></td>");
printf(" <td width=\"46\"></td>");
printf(" <td width=\"90\"></b></td>");
printf(" </tr>\n");
} while ($myrow = mysql_fetch_array($varetabell) AND $myro =
mysql_fetch_array($varetab));
----- Original Message -----
From: "DL Neil" <PHPml@DandE.HomeChoice.co.uk>
To: <petruchek@zsu.zp.ua>; "Raymond Lilleodegard" <raymol@online.no>
Cc: <php-general@lists.php.net>
Sent: Wednesday, February 06, 2002 7:20 PM
Subject: Re: [PHP] Is this possible?
> val,
>
> Surely this would only be possible if "SIZE1" and "P2" [sic - maybe
"SIZE2"] were constants, ie that all small
> packs had SIZE="small" and all large packs were defined as SIZE="large".
> (also that all products had no more than two sizes)
>
> Interesting thought though (subject to the <=2 sizes constraint), could
there be a LEFT JOIN off PRODUCTS, but
> put P1 and P2 into a cartesian product but only selecting where there is
inequality:
>
> WHERE P.NUM=P1.ID AND P.NUM=P2.ID
> AND P1.SIZE <> P2.SIZE
>
> [sorry, machine is busy on something, so haven't prototyped it]
>
> Raymond: is there a SIZE (type of) field? Do the above constraints apply?
What are the table definitions you are
> using? Any chance of some sample data?
>
> Please advise,
> =dn
>
>
> > Let prices(id,price etc.) be table of prices, products(NUM,name etc).
> >
> > Try smth like this:
> >
> > SELECT DISTINCT * FROM PRODUCTS P, PRICES P1, PRICES P2
> > WHERE P.NUM=P1.ID AND P.NUM=P2.ID AND P1.SIZE=SIZE1 AND P2.SIZE=P2
> >
> >
> > Valentin Petruchek (aki Zliy Pes)
> > http://zliypes.com.ua
> > mailto:val@zliypes.com.ua
> > ----- Original Message -----
> > From: "Raymond Lilleodegard" <>
> > To: <php-general@lists.php.net>
> > Sent: Wednesday, February 06, 2002 7:16 PM
> > Subject: [PHP] Is this possible?
> >
> >
> > > Hi!
> > >
> > > I have this tricky case, at lest for me : )
> > >
> > > I'm trying to get some data out of two tables and listing the data in
a
> > > product/price site. But..... :
> > >
> > > I have one table with productinfo and one with prices.
> > > And it is several columns with the same id in the pricetable, because
> > every
> > > product have several sizes.
> > >
> > > So... how do I get only one row from the "product table" and two rows
from
> > > the "price table" in one line in a page?
> > > Is it possible?
> > >
> > >
> > >
> > > Best regards
> > >
> > > Raymond
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> > >
> >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>