bulgaria_mitko Posted December 11, 2006 Share Posted December 11, 2006 i have this problem when i try to display an array information to other page i get only this text "Array" the code im useing in index.php is this (dont pay attention to the text it is in bulgarian):<form action="php.php" method="post">Вашето име: <input type="text" name="ime"><br>Възраст: <input type="text" name="godini"><br>Интереси : <select multiple name="interesi[]"><option value="1">Интернет<option value="2">Музика<option value="3">Кино<option value="4">Филателия</select><input type="submit" value="Изпрати!"></form>and when i try to display the the multiple name selection named "interesi[]" with this code:<?phpecho $_POST['interesi'];?>i only get this: Array (and it must show one of those 4 elements:<option value="1">Интернет<option value="2">Музика<option value="3">Кино<option value="4">Филателия )can someone help me pls? thank you! Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/ Share on other sites More sharing options...
papaface Posted December 11, 2006 Share Posted December 11, 2006 [code]<?phpprint "<pre>";print_r ($_POST['interesi']);print "</pre>";?>[/code]Should do it. Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/#findComment-139116 Share on other sites More sharing options...
bulgaria_mitko Posted December 11, 2006 Author Share Posted December 11, 2006 thanks, but now all i get is this:Array( [0] => 3)witch is not what i want i want one of the interests to show on and the interests are Music, Movies, Internet and Cars (written in bulgarian) isnt it possible to show only the selected word? thanks again! Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/#findComment-139122 Share on other sites More sharing options...
papaface Posted December 11, 2006 Share Posted December 11, 2006 Instead of:[code]<option value="1">Интернет<option value="2">Музика<option value="3">Кино<option value="4">Филателия[/code]use:[code]<option value="Интернет">Интернет<option value="Музика">Музика<option value="Кино">Кино<option value="Филателия">Филателия[/code] Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/#findComment-139125 Share on other sites More sharing options...
bulgaria_mitko Posted December 11, 2006 Author Share Posted December 11, 2006 its the same devnerds i changed it but still the same :( i was thinking this is simple :( Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/#findComment-139129 Share on other sites More sharing options...
papaface Posted December 11, 2006 Share Posted December 11, 2006 It is called "interesi[]" not "interesi". This is probably why you are getting the Array. Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/#findComment-139144 Share on other sites More sharing options...
mansuang Posted December 11, 2006 Share Posted December 11, 2006 You may need loop to display all items.[code]<?phpforeach($_POST['interesi'] AS $select){ echo $select."<br>";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/#findComment-139160 Share on other sites More sharing options...
bulgaria_mitko Posted December 11, 2006 Author Share Posted December 11, 2006 now its not displaying anything i write the code again:<p>Моля попълнете следната информация:<form action="php.php" method="post">Вашето име: <input type="text" name="ime"><br>Възраст: <input type="text" name="godini"><br>Интереси : <select multiple name="interesi[]"><option value="Интернет">Интернет<option value="Музика">Музика<option value="Кино">Кино<option value="Филателия">Филателия</select><input type="submit" value="Изпрати!"></form></p>and php.php:<p>Здравейте,<?phpecho $_POST['ime'];?>, вие сте на<?phpecho $_POST['godini'];?> години!Вашият интерес е свързан с<?phpprint "<pre>";print_r ($_POST['interesi[]']);print "</pre>";?></p>and its not displaying anything Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/#findComment-139162 Share on other sites More sharing options...
bulgaria_mitko Posted December 11, 2006 Author Share Posted December 11, 2006 [quote author=mansuang link=topic=118202.msg482818#msg482818 date=1165860343]You may need loop to display all items.[code]<?phpforeach($_POST['interesi'] AS $select){ echo $select."<br>";}?>[/code][/quote]with this code it is displaying the number of the array Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/#findComment-139164 Share on other sites More sharing options...
mansuang Posted December 11, 2006 Share Posted December 11, 2006 [quote author=bulgaria_mitko link=topic=118202.msg482820#msg482820 date=1165860494]now its not displaying anything i write the code again:<p>Моля попълнете следната информация:<form action="php.php" method="post">Вашето име: <input type="text" name="ime"><br>Възраст: <input type="text" name="godini"><br>Интереси : <select multiple name="interesi[]"><option value="Интернет">Интернет<option value="Музика">Музика<option value="Кино">Кино<option value="Филателия">Филателия</select><input type="submit" value="Изпрати!"></form></p>and php.php:<p>Здравейте,<?phpecho $_POST['ime'];?>, вие сте на<?phpecho $_POST['godini'];?> години!Вашият интерес е свързан с<?phpprint "<pre>";print_r ($_POST['interesi[]']);print "</pre>";?></p>and its not displaying anything [/quote]Try this code in php.php[code]<p>Здравейте,<?phpecho $_POST['ime'];?>, вие сте на<?phpecho $_POST['godini'];?> години!Вашият интерес е свързан с<?phpforeach($_POST['interesi'] AS $select){ echo $select."<br>";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/#findComment-139171 Share on other sites More sharing options...
bulgaria_mitko Posted December 11, 2006 Author Share Posted December 11, 2006 its working great! thank you very much!!!!! :D :D Link to comment https://forums.phpfreaks.com/topic/30249-how-do-u-desplay-arrays-in-php/#findComment-139209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.