Re: Multi dimensional array

From: JDS (jeffrey_at_example.invalid)
Date: 02/16/05


Date: Wed, 16 Feb 2005 09:48:19 -0500

On Tue, 15 Feb 2005 12:07:30 -0800, Stefan Richter wrote:

> I guessed that, but so far I didnt know how, so I thought SOME
> solution is better then none.
>
> Your example definitely helps, but there is still the main point -
>
> Your code example will result in at least 2 different arrays -
> One for the regular values, one for the amount.
>
> I set the amount to "" because it is not coming from the database.
> The database just sends the details of the articles.
>
> Then the user types in the amount he wants to order from that article.
>
> I got working code where I have the data from the database in one
> array,
> and the amount in another, but then I have to loop through them and
> have to assume that index 0 in the one array fits to index 0 in the
> other array -
> if I had all in one array, I wouldn't have that problem..
>
> Do you get what I mean?
>
> Thanks,

No, I don't get what you mean. If you mean to set the value inside the
<input> field to blank (""), then why did you put anything inside the
value? See your original post:

foreach($articleTable as $article) {
?>
<input type="text" name="article[amount]" size="2" maxlength="2"
value="<? $article[amount] ?>"></td>
}

What are you trying to do here? I only say the value is getting set to ""
because the PHP statment <? $article[amount] ?> is not doing anything!!

I still really don't get what you are trying to do. My code example does
not result in two different arrays! My example does not result in any
arrays -- it just prints out stuff. Unless you mean the naming of the
<input> tag which will result in an array being created within whatever
PHP script receives the data.

Ultimately I think you have to rethink your problem a little, and learn
how to create and use multi-dimensional arrays. Hint: Use two for() or
foreach() loops -- one inside the other!

I am trying to be helpful, really, and not trying to be a prick. But I
simply do not see what you are trying to do.

later...

-- 
    JDS | jeffrey@example.invalid
        | http://www.newtnotes.com
  DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/


Relevant Pages

  • Re: rs232...
    ... 'j' for non-equality to BYTESTOREAD in the end of 'do' loop, ... #define BYTESTOREAD 25 //Depicts the amount of bytes to read! ... //immediatelly assigned to this array. ... // from the rs232 port), ...
    (microsoft.public.vc.language)
  • Re: Random numbers with no duplicates
    ... > loop that generates the numbers and does the set insert. ... because it could happen so that rand() returns you the ... Generate array of numbers in order ... Repeat untill you have the amount of numbers you want, ...
    (alt.comp.lang.learn.c-cpp)
  • Re: large data in memory
    ... It sounds like you will be making inefficient use of a significant amount of space. ... For example you may find that you can access only the records actually required with a single query by using an "inner join". ... If you are using only a few elements from a very large array, a "hash table" might provide a better storage solution. ... The id is only a 27 char string. ...
    (microsoft.public.vb.general.discussion)
  • Re: how to vary sorts block?
    ... I want to be able to sort that array by ... def initialize ... Thing = Struct.new(:name,:amount) ...
    (comp.lang.ruby)
  • Re: complicated array
    ... > the columns are account name and amount of order. ... > I need the section where this array would be to look as ... > could refer to that cell to understand its associated ...
    (microsoft.public.excel.worksheet.functions)