| | #1 |
| HyperActive Warrior Join Date: 2010 Location: India
Posts: 159
Thanks: 7
Thanked 1 Time in 1 Post
|
Hello everyone, I am trying to use Multidimensional arrays for sending data to another page but i am not able to retrive data of paths (individual),but i am able to access all the data at a time when i use print_r function . what i want to do : i am trying to send the data (using array) form my video_array.php to sh.php for showing the list of videos which is present in the folder and when user click on any video then it play that vvideo. i am using array so that i can bulid my web page much more dynamic.. please help me .. thanks shubham.. code : video_array.php <?php //$paths = array(); $videos = array(); $videos["101"] = array( "name" => "Engineering Mathenatics-III", "paths" => array( 1010 => "3_sem/video/plcc/a1.mp4", 1011 => "3_sem/video/plcc/a2.mp4", 1012 => "3_sem/video/plcc/a3.mp4", //1013 => "3_sem/video/plcc/DG-L-4.mov", //1014 => "3_sem/video/plcc/DG-L-5.mov", //1015 => "3_sem/video/plcc/DG-L-6.mov", //1016 => "3_sem/video/plcc/DG-L-7.mov", //1017 => "3_sem/video/plcc/DG-L-8.mov", ), ); $videos["102"] = array( "name" => "Programming Language Concepts and Constructs", "paths" => array( 1020 => "3_sem/video/plcc/DG-L-1.mov", 1021 => "3_sem/video/plcc/DG-L-2.mov", 1022 => "3_sem/video/plcc/DG-L-3.mov", 1023 => "3_sem/video/plcc/DG-L-4.mov", ), ); ?> sh.php <?php include("include/video_array.php"); include("include/list_array.php"); $subject_id = $_GET["id"]; $subject = $subjects[$subject_id]; $name = $subject["name"]; $type = $subject["type"]; $code = $subject["code"]; $t_credits = $subject["t_credits"]; $video_id = $_GET["id"]; //$path_id = $_GET["id"]; $video = $videos[$video_id]; $v_name = $video["name"]; $path = $video["paths"] //$paths = $video[$video_id]; ?> <!DOCTYPE html> <html lang="en"> <head> <title><?php echo $name; ?></title> <link href="css/style.css" type="text/css" rel="stylesheet" /> </head> <body> <div id="main"> <header> <h1><?php echo "$name<br />" . "Paper type: $type<br />" . "Subject code: $code<br />" . "Totle Credits: $t_credits"; ?> </h1> </header> <div id="video_box"> <h2>Videos</h2> <div id="video_tab"> <a href="#"><img src="image/video1.png"></a> </div> </div> <div id="pdf"> <h2>PDF</h2> </div> </div> <?php //foreach ($videos[paths] as $path) { //echo $path "<br />"; //} ?> <pre> <?php // echo $subject_id . "\n"; // var_dump($subject); //echo $video_id . "\n"; //var_dump($video); ?> </pre> </body> <?php ?> |
| |
| | #2 |
| Warrior Member Join Date: 2015
Posts: 25
Thanks: 0
Thanked 1 Time in 1 Post
|
It looks sloppy and inefficient (from a programmers point of view), but one of the most simple and easiest ways to retrieve data from the array tree is to do multiple loops(as foreach) such as "foreach($one as $two){foreach($two as $three){print $three; } }." Just put multiple foreach inside themselves like that until it outputs the info you want. You can save the info into another array you have created by using array_push() maybe. Otherwise, you'll have to mess with doing some more complicated things to output your array using "=>" which is more efficient, but not beginner friendly .
|
| |
| | #3 |
| HyperActive Warrior Join Date: 2010 Location: India
Posts: 159
Thanks: 7
Thanked 1 Time in 1 Post
|
Hi there , please add me in your skype (shubham.raj3) . |
| |
| | #5 |
| DATASTYLING - Book Design War Room Member Join Date: 2011 Location: Cebu Philippines
Posts: 32
Thanks: 0
Thanked 3 Times in 3 Posts
|
try using json via xml.
|
|
BOOK DESIGN & LAYOUT / WEB DEVELOPMENT WEBSITE: www.datastyling.com (book design & layout - $95 only) www.thorhosting.co (hosting with free fully functional website) www.infoph.com (open internet directory, jobs, classifieds & news) SKYPE: datastyling FACEBOOK: https://www.facebook.com/bookdesignservices | |
| |
|
| Bookmarks |
| Tags |
| array, php |
| |