Re: Multiple MySQL Queries

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

 



Keep in mind that you can use name=var[] value=value1, name=var[]
value=value2 and php will create an array as $_REQUEST['var'] with each of
your values. The keys are numbered and don't count on what order they'll
come through.
Jerry Wilborn
jerrywilborn@xxxxxxxxx


On Tue, Aug 4, 2009 at 10:47 AM, Bastien Koert <phpster@xxxxxxxxx> wrote:

> On Tue, Aug 4, 2009 at 11:40 AM, <sono-io@xxxxxxxxxxxxx> wrote:
> >        Is what I'm looking to do not possible in PHP?  I've come close
> with
> > a JavaScript version, but I'd rather not rely on everyone having JS
> turned
> > on.  Or am I stuck having to use JS?
> >
> > Thanks again,
> > Frank
> >
> >
> >>        I'd like to revisit this one last time.  Below is the revised
> code
> >> I'm using, but I don't like having individual 'Add To Cart' buttons for
> each
> >> item.  I've tried to find a way to have only one that resides outside
> the
> >> nested tables for all items, but without luck.  It would need to send
> every
> >> item that has a quantity to the cart, but only those items.  The URL
> that
> >> would be passed needs to look like this:
> >>
> >>
> >>
> /shop.cgi?c=viewcart.htm&itemid=P74S&i_P74S=80&S2448S&i_S2448S=100&AC&i_AC=26
> >>
> >> (The above URL is sending 3 items and their quantities to the cart; 80 -
> >> P74S, 100 - S2448S and 26 - AC.)
> >>
> >>        Thanks again for all your help.  I'm learning a lot on this list
> -
> >> albeit slowly! ;)
> >>
> >> Regards,
> >> Frank
> >>
> >> ------------------------
> >>
> >> <?php
> >> $cats = array('02121-19222-13349-11451' => 'Stationary
> >> Posts','04103-99222-48340-11422' => 'Solid Galvanized Shelves');
> >>
> >> echo '<table border="1"><tr>';
> >>
> >> foreach ( $cats AS $cat => $title) {
> >>  echo <<<START
> >>
> >> <td valign="top">
> >>  <table border="1">
> >>      <tr><th align="center" colspan="4">{$title}</th></tr>
> >>      <tr>
> >>          <td class="text-header" align="center">Item#</td>
> >>          <td class="text-header" align="center">Description<br />
> >>                   <span class="text-small">(Click for more
> >> info)</span></td>
> >>          <td class="text-header" align="center">Price</td>
> >>          <td class="text-header" align="center">Qty</td>
> >>      </tr>
> >>
> >> START;
> >>
> >>  $cat = mysql_real_escape_string($cat, $db);
> >>  $SQL = "SELECT itemid,description,unitprice
> >>          FROM catalog
> >>          WHERE categories='$cat'
> >>          ORDER BY itemid";
> >>
> >>  if ( ($result = mysql_query($SQL, $db)) !== false ) {
> >>      while ( $item = mysql_fetch_assoc($result) ) {
> >>          $price = "$" . number_format($item['unitprice'],2);
> >>          echo <<<ROW
> >>
> >>  <tr>
> >>      <td class="text-med">{$item['itemid']}</td>
> >>      <td class="text-med"><a
> >>
> href="/shop.cgi?c=detail.htm&itemid={$item['itemid']}">{$item['description']}</a></td>
> >>      <td class="text-med" align="right">{$price}</td>
> >>          <td class="text-med">
> >>              <form action="/shop.cgi" method="get">
> >>            <input type="hidden" name="itemid" value="{$item['itemid']}"
> />
> >>            <input type="text" name="i_{$item['itemid']}" value=""
> size="4"
> >> />
> >>            <input type="hidden" name="c" value="viewcart.htm" />
> >>            <input type="image" src="/graphics/addtocart.png"
> >> name="addToCartButton" alt="Add To Cart" />
> >>                  </form>
> >>        </td>
> >>  </tr>
> >>
> >> ROW;
> >>      }
> >>
> >>  } else {
> >>      echo "No results for category #{$cat}!";
> >>  }
> >>  echo '</table></td>';
> >> }
> >> echo '</tr></table>';
> >> ?>
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
> You could do it with PHP, but you would still need to loop through all
> the data in the cart to find the element(s) to update. This can be
> done via a straight submit button where you send all the data to the
> server and the code walks thru the current contents
>
> --
>
> Bastien
>
> Cat, the other other white meat
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux