webdevdea Posted July 3, 2013 Share Posted July 3, 2013 I am supposed to have an array so that when you choose a customer and one of the information items, its displays, well its almost there here is my php and html, when you run it it hast cust_num or cust_city or cust_state instead of the data itself so help please <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Didja Know?r</title> </head> <body> <h1>Didja Know?</h1> <?php //create arrays $cust_num = array ( "DeAnna" => 069, "Joshua" => 088, "Eden" => 087, "Aubrey" => 2009 ); $cust_addr = array ( "DeAnna" => 102, "Joshua" => 113, "Eden" => 104, "Aubrey" => 420 ); $cust_city = array ( "DeAnna" => "Atlanta", "Joshua" => "Columbus", "Eden" => "Smyrna", "Aubrey" => "Vinnings" ); $cust_email = array ( "DeAnna" => "deanna@gmail.com", "Joshua" => "josh@gmail.com", "Eden" => "eden@gmail.com", "Aubrey" => "Aubrey@gmail.com" ); //set up master array $distance = array ( "DeAnna" => $cust_num, "Joshua" => $cust_addr, "Eden" => $cust_city, "Aubrey" => $cust_email ); $cust_name = filter_input(INPUT_POST, "cust_name"); $cust_info = filter_input(INPUT_POST, "cust_info"); $result = $distance[$cust_name][$cust_info]; print "<h3>$cust_name and $cust_info is $result .</h3>"; ?> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DIDJA KNOW</title> </head> <body> <h1>DIDJA KNOW</h1> <form action = "http://localhost/Assignments php class/assign7.php" method = "post"> <table border = "1"> <tr> <th>Customer Name</th> <th>Customer Info</th> </tr> <!-- note each option value is a string --> <tr> <td> <select name = "cust_name"> <option value = "DeAnna">DeAnna</option> <option value = "Joshua">Joshua</option> <option value = "Eden">Eden</option> <option value = "Aubrey">Aubrey</option> </select> </td> <td> <select name = "cust_info"> <option value = "cust_num">Customer Number</option> <option value = "cust_addr">Address</option> <option value = "cust_city">City</option> <option value = "cust_email">email</option> </select> </td> </tr> <tr> <td colspan = "2"> <input type = "submit" value = "Didja Know This?" /> </td> </tr> </table> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/ Share on other sites More sharing options...
trq Posted July 3, 2013 Share Posted July 3, 2013 Can you explain to me exactly how you expect your arrays to work as they are currently? This will help you think your problem through. As it stands, your arrays make little sense. Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/#findComment-1439171 Share on other sites More sharing options...
webdevdea Posted July 3, 2013 Author Share Posted July 3, 2013 Ok a dropdown comes up and you choose a person's name, then in another drop down you choose customer number,address,city,email and it is supposed to come up with the name, the data name and the data it comes up with the name and the variable name of the data but that's it.. does that help you ? Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/#findComment-1439172 Share on other sites More sharing options...
webdevdea Posted July 3, 2013 Author Share Posted July 3, 2013 you can go to this link and see what is happening, its a link from an old course I took but I can still up load files and play with them http://www.ctcsports.org/upload/Fall2012/CIST1520/900104329/Assignment13/Assignment7.html Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/#findComment-1439173 Share on other sites More sharing options...
trq Posted July 3, 2013 Share Posted July 3, 2013 I understand what it is you are trying to do. I want you to explain to me what you think your current implementation actually does. Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/#findComment-1439174 Share on other sites More sharing options...
webdevdea Posted July 3, 2013 Author Share Posted July 3, 2013 (edited) Oh ok, lol let me check it out and see, Ok so I have changed my php could you see if its anything close to right lol <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Didja Know?r</title> </head> <body> <h1>Didja Know?</h1> <?php //create arrays $cust069 = array ( "cust_name" => "DeAnna", "cust_addr" => 103, "cust_city" => "Atlanta", "cust_email" => "d@d.com" ); $cust088 = array ( "cust_name" => "Josh", "cust_addr" => 104, "cust_city" => "Columbus", "cust_email" => "J@J.com" ); $cust087= array ( "cust_name" => "Eden", "cust_addr" => 107, "cust_city" => "Smyrna", "cust_email" => "E@E.com" ); $cust2009 = array ( "cust_name" => "Aubrey", "cust_addr" => 103, "cust_city" => "Atlanta", "cust_email" => "A@A.com" ); //set up master array $customers = array ( "069" => $cust069, "cust088" => $cust088, "cust087" => $cust087, "cust2009" => $cust2009 ); $cust_name = filter_input(INPUT_POST, "cust_name"); $cust_info = filter_input(INPUT_POST, "cust_info"); $customers = $customers[$cust_name][$cust_info]; print "<h3>$cust_name and $cust_info is $customers .</h3>"; ?> </body> </html> I know I have something worded wrong, one of my variables maybe in the wrong place???? Edited July 3, 2013 by webdevdea Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/#findComment-1439176 Share on other sites More sharing options...
webdevdea Posted July 3, 2013 Author Share Posted July 3, 2013 I changed the html some <td> <select name = "cust_name"> <option value = "DeAnna">069</option> <option value = "Joshua">088</option> <option value = "Eden">087</option> <option value = "Aubrey">2009</option> </select> </td> <td> <select name = "cust_info"> <option value = "cust_name">Customer Name</option> <option value = "cust_addr">Address</option> <option value = "cust_city">City</option> <option value = "cust_email">email</option> </select> </td> </tr> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Didja Know?r</title> </head> <body> <h1>Didja Know?</h1> <?php //create arrays $cust069 = array ( "cust_name" => "DeAnna", "cust_addr" => 103, "cust_city" => "Atlanta", "cust_email" => "d@d.com" ); $cust088 = array ( "cust_name" => "Josh", "cust_addr" => 104, "cust_city" => "Columbus", "cust_email" => "J@J.com" ); $cust087= array ( "cust_name" => "Eden", "cust_addr" => 107, "cust_city" => "Smyrna", "cust_email" => "E@E.com" ); $cust2009 = array ( "cust_name" => "Aubrey", "cust_addr" => 103, "cust_city" => "Atlanta", "cust_email" => "A@A.com" ); //set up master array $customers = array ( "069" => $cust069, "cust088" => $cust088, "cust087" => $cust087, "cust2009" => $cust2009 ); $cust_name = filter_input(INPUT_POST, "cust_name"); $cust_info = filter_input(INPUT_POST, "cust_info"); $customers = $customers[$cust_name][$cust_info]; print "<h3>$cust_name and $cust_info is $customers .</h3>"; ?> </body> </html> so I have something confused when calling out the $cust_info variable Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/#findComment-1439178 Share on other sites More sharing options...
webdevdea Posted July 3, 2013 Author Share Posted July 3, 2013 I worked on the Php file a little more, maybe closer? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Didja Know?</title> </head> <body> <h1>Didja Know?</h1> <?php //create arrays $cust069 = array ( "cust_name" => "DeAnna", "cust_addr" => 103, "cust_city" => "Atlanta", "cust_email" => "d@d.com" ); $cust088 = array ( "cust_name" => "Josh", "cust_addr" => 104, "cust_city" => "Columbus", "cust_email" => "J@J.com" ); $cust087= array ( "cust_name" => "Eden", "cust_addr" => 107, "cust_city" => "Smyrna", "cust_email" => "E@E.com" ); $cust2009 = array ( "cust_name" => "Aubrey", "cust_addr" => 103, "cust_city" => "Atlanta", "cust_email" => "A@A.com" ); //set up master array $customers = array ( "cust069" => $cust069, "cust088" => $cust088, "cust087" => $cust087, "cust2009" => $cust2009 ); $cust_name = filter_input(INPUT_POST, "cust_name"); $cust_info = filter_input(INPUT_POST, "cust_info"); $did_ja_know = $customers[$cust_name][$cust_info]; print "<h3>$cust_name and $cust_info is $did_ja_know.</h3>"; ?> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/#findComment-1439182 Share on other sites More sharing options...
webdevdea Posted July 3, 2013 Author Share Posted July 3, 2013 Ok here is what I am working with right now, I still am really confused as to how I am messing up.. Help please and thank you .. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Didja Know?</title> </head> <body> <h1>Didja Know?</h1> <?php //create arrays $cust1 = array ( "CustName" => "Fred", "CustAddress" => "123", "CustCity" => "Atlanta", "CustState" => "GA" ); $cust = array ( "CustName" => "dred", "CustAddress" => 1293, "CustCity" => "Atlanhta", "CustState" => "GA" ); $cust3 = array ( "CustName" => "Frsded", "CustAddress" => "132423", "CustCity" => "Atlan2343ta", "CustState" => "G23A" ); $cust4 = array ( "CustName" => "Fre34d", "CustAddress" => "114323", "CustCity" => "Atlafdasfnta", "CustState" => "GafdasA" ); //set up master array $customers = array ( "001" => $cust1, "002" => $cust2, "003" => $cust3, "004" => $cust4 ); $CustName = filter_input(INPUT_POST, "CustName"); $cust_info = filter_input(INPUT_POST, "cust_info"); $did_ja = $customers[$CustName][$cust_info]; print "<h3>$CustName and $cust_info is $did_ja. </h3>"; ?> </body> </html> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html lang="EN" dir="ltr" xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DIDJA KNOW</title> </head> <body> <h1>DIDJA KNOW</h1> <form action = "http://localhost/Assignments php class/assign7.php" method = "post"> <table border = "1"> <tr> <th>Customer Number</th> <th>Customer Info</th> </tr> <!-- note each option value is a string --> <tr> <td> <select name = "CustName"> <option value = "DeAnna">069</option> <option value = "Josh">088</option> <option value = "Eden">087</option> <option value = "Aubs">2009</option> </select> </td> <td> <select name = "cust_info"> <option value = "CustName">Customer Name</option> <option value = "CustAddress">Address</option> <option value = "CustCity">City</option> <option value = "CustState">state</option> </select> </td> </tr> <tr> <td colspan = "2"> <input type = "submit" value = "Didja Know This?" /> </td> </tr> </table> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/#findComment-1439284 Share on other sites More sharing options...
webdevdea Posted July 4, 2013 Author Share Posted July 4, 2013 Can you explain to me exactly how you expect your arrays to work as they are currently? This will help you think your problem through. As it stands, your arrays make little sense. Still having trouble getting my array's to associate, could someone give me a hint as to where I am going wrong? Can you explain to me exactly how you expect your arrays to work as they are currently? This will help you think your problem through. As it stands, your arrays make little sense. v Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/#findComment-1439367 Share on other sites More sharing options...
Solution webdevdea Posted July 4, 2013 Author Solution Share Posted July 4, 2013 Ok I got the mission Accomplished Thank for the help guys.. Quote Link to comment https://forums.phpfreaks.com/topic/279813-multi-diminutional-array-help/#findComment-1439425 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.