You are here: Re: How do I execute sql with a submit button? « PHP SQL « IT news, forums, messages
Re: How do I execute sql with a submit button?

Posted by John MacLeod on 11/15/05 23:12

Hilarion,

Thank you...thank you...thank you...

...it's now working...but of course I'm not satisfied to stop there...big
surprise...

There are two more things I'd like to do...

1. (should be fairly easy) add a button to print the list that's produced
2. (should be harder) list the totals of each product to be ordered

The first one should be fairly easy and I may (or may not) be able to figure
it out on my own...but the second one is a SQL query that is beyond me and I
will need some help with it...

....I'll pose my question here but should I be starting a new topic for this
question?

Currently, all of the products to be ordered are listed including...

Product code (product)
Description (title)
Quantity (quantity)
Price (price)
Order ID (cart_order_id)

If there was one order that contained the product "Apple Brown Betty" with a
quantity of 1, and a second order that contained the product "Apple Brown
Betty" with a quantity of 2...they currently show up as two different lines
in the list. I would like the product "Apple Brown Betty" to show up once in
the list with a quantity of 3 (the total quantity we need to order from our
supplier).

What would the query be to produce this result?

I assume I would no longer be able to have the Order ID in the list as the
total of 3 would come from two different orders...or can both Order ID's be
listed along with the product total?

The current query used is...

$sql_select = mysql_query(
'SELECT product, title, quantity, price, cart_order_id ' .
'FROM ' . $prefix . 'store_order_inv ' .
'WHERE order_from_supplier = 1 ' .
'ORDER BY product ASC'
);

....if you, or anyone else, can offer advice, it would again be
appreciated...

Thanks again,
John

P.S. Please let me know if I should be starting a new thread for this
question...

"Hilarion" <hilarion@SPAM.op.SMIECI.pl> wrote in message
news:dlddis$447$1@news.onet.pl...
>> echo" <center><font face=\"arial\" size=\"4\">Order from
>> Supplier<br></font>
>>
>> <font face=\"arial\" size=\"2\">$date</font></center><br><br>";
>>
>> ////// Reset database button /////////
>> //////
>> echo"<form name=\"reset_database\" method=\"post\" action=\"<? $PHP_SELF
>> ?>\">
>>
>> <center><input type=\"submit\" name=\"enter_data\" value=\"Reset database
>> after printing\"></center>
>>
>> </form>";
>
> Change above block to HTML with PHP inserted instead of all PHP:
>
> ?>
> <center><font face="arial" size="4">Order from Supplier<br></font>
> <font face="arial" size="2"><?php echo $date; ?></font></center><br><br>
>
> <form name="reset_database" method="post" action="<?php
> echo htmlspecialchars( $_SERVER['PHP_SELF'] );
> ?>">
> <center><input type="submit" name="enter_data"
> value="Reset database after printing"></center>
> </form>
> <?php
>
>
>> error_reporting( E_ALL );
>
> This one should be before session_start call after first "<?php"
> or after those includes.
>
>
>> if ($enter_data) {
>
> Should be:
>
> if (!empty($_REQUEST['enter_data'])) {
>
>> $sql = mysql_query("UPDATE cubecartstore_order_inv SET
>> order_from_supplier = '0'");
>
> Add error checking:
>
> if ($sql===FALSE)
> {
> die( 'Error executing query: ' . mysql_error() );
> }
>
>
>> }
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация