array didn't work

This is a discussion on "array didn't work" within the PHP Forum section. This forum, and the thread "array didn't work are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Aug 29th, 2007, 23:15
Junior Member
Join Date: Nov 2006
Location: us
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
array didn't work

Hi,
Not sure why the array page is not working when I called it on the browser. Can someone give a tip to see what was it wrong in the syntax? Much appreciated!

PHP: Select all

<?php

        
//assign the multiple array
        
$price[0][0]=12;
        
$price[0][1]=25;
        
$price[1][0]=36;
        
$price[1][1]=48;
        
$price[2[0]=11;
        
$price[2][1]=77;
        
        
//assign the multiple array
        
$data=array("name"=>array("Linda""Alice","Elvin"),
                    
"value"=>array("123","456","789"),
                    
"address"=>array("Frankfurt","Zurich","Madrid"));
        
        
        
//assign the multiple array
        
for($a=0$a<3$a++){
            echo 
"<p>";
                for(
$b=0$b<2;$a++){
                    echo 
"\$price[$a][$b] = ".$price[$a][$b]. "<br>";
                }
            echo 
"</p>";
        }
        
        
//displaying table with multiple array
        
echo "<table bgcolor='#ffccff' border='2' width='70%'><tr>";
            for(
$a=0$a<3$a++){
                echo 
"<td>".$data["name"][$a]."</td>";
            }
            
        echo 
"</tr><tr>";
            for(
$a=0$a<3;$a++){
                echo 
"<td>".$$data["value"][$a]."</td>";
            }
        echo 
"</tr><tr>";
            for(
$a=0$a<3$a++){
                echo 
"<td>".$data.["address"][$a]. "</td>";
            }
        echo 
"</tr></table>";
        
?>

Last edited by Daniel; Aug 30th, 2007 at 13:15.
Reply With Quote

  #2 (permalink)  
Old Aug 29th, 2007, 23:34
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Blake121
Re: array didn't work

Well for a start this:

PHP: Select all

                for($b=0$b<2;$a++){ 

should be this:

PHP: Select all

                for($b=0$b<2;$b++){ 

You've tried to make the the "a" variable increase instaed of the "b" variable your using in that loop

You have forgotten a "[" 7th line

PHP: Select all

        $price[2[0]=11
Also I don't know why you used two $ signs here:

PHP: Select all

$$data["value"][$a
And last but not least; Right at the end you have an extra concat dot after $data that shouldn't be there. You have:

PHP: Select all

                echo "<td>".$data.["address"][$a]. "</td>"
which should be
PHP: Select all

                echo "<td>".$data["address"][$a]. "</td>"
Hope this helps,
Blake

Last edited by Blake121; Aug 29th, 2007 at 23:41.
Reply With Quote
  #3 (permalink)  
Old Aug 30th, 2007, 18:28
Junior Member
Join Date: Nov 2006
Location: us
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Re: array didn't work

Quote:
Originally Posted by Blake121 View Post
Well for a start this:

PHP: Select all

                for($b=0$b<2;$a++){ 

should be this:

PHP: Select all

                for($b=0$b<2;$b++){ 

You've tried to make the the "a" variable increase instaed of the "b" variable your using in that loop

You have forgotten a "[" 7th line

PHP: Select all

        $price[2[0]=11
Also I don't know why you used two $ signs here:

PHP: Select all

$$data["value"][$a
And last but not least; Right at the end you have an extra concat dot after $data that shouldn't be there. You have:

PHP: Select all

                echo "<td>".$data.["address"][$a]. "</td>"
which should be
PHP: Select all

                echo "<td>".$data["address"][$a]. "</td>"
Hope this helps,
Blake
I thank you very much, it works now.
Reply With Quote
  #4 (permalink)  
Old Aug 30th, 2007, 22:01
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Blake121
Re: array didn't work

No Problem
Reply With Quote
Reply

Tags
array didnt work

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript menu - does not work on title page, but does work on other pages Crystal Phoenix Starting Out 4 Mar 24th, 2008 19:40
simple js doesn't work with IE7 (work with FF1.5) gpazi JavaScript Forum 1 Jun 10th, 2007 11:00
Top 4 array to text box buzcajun Flash & Multimedia Forum 10 Sep 14th, 2006 19:13
Sorting a new array from an existing array Ozeona Flash & Multimedia Forum 2 Sep 20th, 2005 08:43
array unable to check another array so as to be displayed Ozeona Flash & Multimedia Forum 1 Aug 5th, 2005 10:26


All times are GMT. The time now is 05:36.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43