Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Php zend practice - help me solve this
Old 06-04-2010, 03:24 AM Php zend practice - help me solve this
Novice Talker

Posts: 6
Name: Ryan Murphy
Trades: 0
I am currently studying for my qualification in becoming a Zend PHP programmer. And we were given this broken script to fix, can you help me fix this?

Code:
<?php 
$lang_eng = array("English","Japanese","Chinese","Hungarian","Arabic","French","Russian","Thai","Korean");
$values = array("English","Japanese","Chinese","Hungarian","Arabic","French","Russian","Thai","Korean");
$header = "Select Your Language";

function selectLang($header,$lang_eng,$values){

echo $header;
echo "<br />";
echo "<form method='post' style='margin-left:-5px; margin-bottom:5px;' action=''>";
foreach($lang_eng as $list){
foreach ($values as $values1){
echo "<label>";
echo "<input type='radio' name='languages[]' value='$values1' />" . $list;
echo "</label>";};};

echo "<br /><br />";
echo "<input type='submit' value='Send' name='poll' />";
echo "</form>";
echo "Change the Colour Scheme<br>";
echo "<button onclick='JavaScript:changeSheets(1)' class='button'></button>";
echo "<button onclick='JavaScript:changeSheets(2)' class='button1'></button>";
echo "<button onclick='JavaScript:changeSheets(3)' class='button2'></button>";
echo "<button onclick='JavaScript:changeSheets(4)' class='button3'></button>";

echo "</div>";

};

echo selectLang($header,$lang_eng,$values);
This codes output is odd to say the least.
All suggestions, improvements and fixes are welcome.
RyanMurphy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-04-2010, 04:32 AM Re: Php zend practice - help me solve this
NullPointer's Avatar
Will Code for Food

Posts: 2,815
Name: Matt
Location: Irvine, CA
Trades: 0
How exactly is it broken? There were no error messages when I ran it. What is it supposed to do that it isn't doing or isn't doing correctly?
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
NullPointer is online now
Reply With Quote
View Public Profile Visit NullPointer's homepage!
 
Old 06-04-2010, 04:53 AM Re: Php zend practice - help me solve this
Novice Talker

Posts: 6
Name: Ryan Murphy
Trades: 0
When the script is run, no errors are generated, thats why fixing this has been said to be a little tricky for sum.

As you notice , when run, several of each language appears with a checkbox next to them, what needs to happen is have only one of every country?

I hope I made sense, do you understand what i was trying to say?
RyanMurphy is offline
Reply With Quote
View Public Profile
 
Old 06-04-2010, 05:12 AM Re: Php zend practice - help me solve this
Novice Talker

Posts: 6
Name: Ryan Murphy
Trades: 0
I have been working on it and tried this but no luck so far, for some reason when i run this code, instead of showing several of each language in the variable array $lang_eng, it only outputs 'Korean'. any suggestions?

Code:
<?php 
$lang_eng = array("English","Japanese","Chinese","Hungarian","Arabic","French","Russian","Thai","Korean");
$values = array("English","Japanese","Chinese","Hungarian","Arabic","French","Russian","Thai","Korean");
$header = "Select Your Language";

function selectLang($a,$b,$c){

$html =  $a;
$html .= "<br />";
$html .= "<form method='post' style='margin-left:-5px; margin-bottom:5px;' action=''>";
foreach($b as $list){
}
foreach ($c as $values1){
}
$html .= "<label>";
$html .= "<input type='radio' name='languages[]' value='$values1' />" . $list;
$html .= "</label>";

$html .= "<br /><br />";
$html .= "<input type='submit' value='Send' name='poll' />";
$html .= "</form>";
$html .= "Change the Colour Scheme<br>";
$html .= "<button onclick='JavaScript:changeSheets(1)' class='button'></button>";
$html .= "<button onclick='JavaScript:changeSheets(2)' class='button1'></button>";
$html .= "<button onclick='JavaScript:changeSheets(3)' class='button2'></button>";
$html .= "<button onclick='JavaScript:changeSheets(4)' class='button3'></button>";

$html .= "</div>";

return $html;
};

$output = selectLang($header,$lang_eng,$values);
echo $output;
RyanMurphy is offline
Reply With Quote
View Public Profile
 
Old 06-04-2010, 06:37 AM Re: Php zend practice - help me solve this
Novice Talker

Posts: 6
Name: Ryan Murphy
Trades: 0
I have had a bit of progress further, i can get the right amount of checkboxes to turn up, working correctly but no text appears along side them.

Any suggestions?

Code:
$lang_eng = array("English","Japanese","Chinese","Hungarian","Arabic","French","Russian","Thai","Korean");
$values = array("English","Japanese","Chinese","Hungarian","Arabic","French","Russian","Thai","Korean");
$header = "Select Your Language";

function selectLang($header,$lang_eng,$values){

echo $header;
echo "<br />";
echo "<form method='post' style='margin-left:-5px; margin-bottom:5px;' action=''>";
while(list(,$list) = each($lang_eng) && list(,$values1) = each($values)) {
echo "<label>";
echo "<input type='radio' name='languages[]' value='$values1' />" . $list;
echo "</label>";}

echo "<br /><br />";
echo "<input type='submit' value='Send' name='poll' />";
echo "</form>";
echo "Change the Colour Scheme<br>";
echo "<button onclick='JavaScript:changeSheets(1)' class='button'></button>";
echo "<button onclick='JavaScript:changeSheets(2)' class='button1'></button>";
echo "<button onclick='JavaScript:changeSheets(3)' class='button2'></button>";
echo "<button onclick='JavaScript:changeSheets(4)' class='button3'></button>";

echo "</div>";

};
echo selectLang($header,$lang_eng,$values)
RyanMurphy is offline
Reply With Quote
View Public Profile
 
Old 06-04-2010, 06:41 AM Re: Php zend practice - help me solve this
Novice Talker

Posts: 6
Name: Ryan Murphy
Trades: 0
SOLVED
Switched the foreach with a while
Can anyone tell me why the foreach wouldnt work with 2 arrays?

Code:
<?php 
$lang_eng = array("English","Japanese","Chinese","Hungarian","Arabic","French","Russian","Thai","Korean");
$values = array("English","Japanese","Chinese","Hungarian","Arabic","French","Russian","Thai","Korean");
$header = "Select Your Language";

function selectLang($header,$lang_eng,$values){

echo $header;
echo "<br />";
echo "<form method='post' style='margin-left:-5px; margin-bottom:5px;' action=''>";
while(list(,$values1) = each($values) AND list(,$list) = each($lang_eng)) {
echo "<label>";
echo "<input type='radio' name='languages[]' value='$values1' />" . $list;
echo "</label>";}

echo "<br /><br />";
echo "<input type='submit' value='Send' name='poll' />";
echo "</form>";
echo "Change the Colour Scheme<br>";
echo "<button onclick='JavaScript:changeSheets(1)' class='button'></button>";
echo "<button onclick='JavaScript:changeSheets(2)' class='button1'></button>";
echo "<button onclick='JavaScript:changeSheets(3)' class='button2'></button>";
echo "<button onclick='JavaScript:changeSheets(4)' class='button3'></button>";

echo "</div>";

}

?>
RyanMurphy is offline
Reply With Quote
View Public Profile
 
Old 06-12-2010, 07:57 PM Re: Php zend practice - help me solve this
JeremyMiller's Avatar
WT Moderator

Posts: 1,712
Name: Jeremy Miller
Location: Las Vegas, NV
Trades: 0
Thanks for updating us with your solution, Ryan. Best wishes on your testing.
__________________
Jeremy Miller

Please login or register to view this content. Registration is FREE
JeremyMiller is offline
Reply With Quote
View Public Profile Visit JeremyMiller's homepage!
 
Reply     « Reply to Php zend practice - help me solve this
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.18365 seconds with 12 queries