PHP - Foreach Help For A Noob
Hi guys, forum noob here.
I'm very new to php and i'm trying to build a simple food order shopping cart. I'm using DW as a crutch at the moment just to get a feeling of how php works. I have a page where a user can select food extras to add to thier food item using checkboxes. heres the recordset for getting extras. $colname_rs_addedextras = "1"; if (isset($_GET['idfooditem'])) { $colname_rs_addedextras = $_GET['idfooditem']; } mysql_select_db($database_dbconnect, $dbconnect); $query_rs_addedextras = sprintf("SELECT extra.idextra, extra.extraName, extra.extraPrice, addedextras.extraFree FROM addedextras, extra WHERE fooditemID = %s AND addedextras.extraID = extra.idextra", GetSQLValueString($colname_rs_addedextras, "int")); $rs_addedextras = mysql_query($query_rs_addedextras, $dbconnect) or die(mysql_error()); $row_rs_addedextras = mysql_fetch_assoc($rs_addedextras); $totalRows_rs_addedextras = mysql_num_rows($rs_addedextras); Here is the code i'm strugling with. // Submit to Order Form ///////////////////////////// if (isset($_POST["addtoorderButton"])) { mysql_query("INSERT INTO cart(cookieID, customerID, fooditemID, foodItemName, foodItemPrice) VALUES('$cookieID', '$customerID', '$fooditemID', '$foodItemName', '$foodItemPrice' ) ") or die(mysql_error()); if ($_POST['checkbox'] != NULL) { $cart_id = mysql_insert_id(); foreach($_POST['checkbox'] as $key => $value) { $extraName = $row_rs_addedextras['extraName']; $extraPrice = $row_rs_addedextras['extraPrice']; $extraFree = $row_rs_addedextras['extraFree']; //echo $key; mysql_query("INSERT INTO cartextras(cartID, cookieID, extraName, extraID, extraPrice, extraFree) VALUES('$cart_id', '$cookieID', '$extraName', '$key', '$extraPrice', '$extraFree') ") or die(mysql_error()); } } } The code kinda works, I just can't figure out how to add the extraPrice and extraFree also. Any kind of guidence would be very apprieated as I have been trying to figure this out for a couple of days now, wanted to figure it out by myself because I think to learn faster that way. Similar Tutorialshey guys! Im trying to get hashtags out of a string. The function works so far- but i cant transfer the insides of the preg_match_all array into the string. A hint would be fine already. Thanks in advance- and here is some code Code: [Select] <?php //example string $strcontent = "ima string... #wat #taggy #taggytag im in your stringz, stealing your charz!"; //find hashtags preg_match_all("/(#\w+)/", $strcontent, $matches); echo $matches; //the output is just "array" -> why? foreach ($matches as $match) { // $tempmatch=$match[1]; #####like this? //hiding the hashtags via span $strtemp="<br>ima span<br>" . $match . "<br>ima /span<br>" . $strcontent; $strcontent = $strtemp; echo $strcontent; } #echo $strcontent; # <span style="display:none;"></span> ?> Please bear with me. In an html file there is an <!-- BEGIN poll --> ..... <!-- END poll --> I need to draw a separation hr between all rows escept the first one. I believe I need a counter. Please show me how to do this. Thank you. This topic has been moved to Application Frameworks. http://www.phpfreaks.com/forums/index.php?topic=355772.0 I'm not sure if the title explains it very well, but here is an image of it. I am trying to figure out how to access the option selected (equal, not equal, etc.), along with its input box, for each column (the checkboxes on the right) selected. The purpose of this is to allow a non-programming administrator user to create a custom query to access information. I can find out which checkboxes are selected no problem, but finding the accompanying drop-down option and input box is difficult for me. How do I do this? If you have a suggestion on how to change it, I'm very open. Thank you in advance! Code: [Select] if(!isset($_POST['submit'])) { echo " <form method='post'> <table> <tr> <td valign='top'>SELECT</td> <td valign='top'> <table>"; // LIST ALL COLUMNS IN A TABLE $result = mysql_query("SELECT * FROM table_name") or die(mysql_error()); $rowcount=mysql_num_rows($result); $y=mysql_num_fields($result); for ($x=0; $x<$y; $x++) { echo " <tr> <td> <input type='checkbox' name='fields[]' value='".mysql_field_name($result, $x)."'>".mysql_field_name($result, $x)." </td> </tr>"; } echo " </table> </td> <td valign='top'>FROM allocations</td> <td valign='top'>WHERE</td> <td> <table>"; // LIST ALL COLUMNS IN A TABLE $result = mysql_query("SELECT * FROM table_name") or die(mysql_error()); $rowcount=mysql_num_rows($result); $y=mysql_num_fields($result); for ($x=0; $x<$y; $x++) { echo " <tr> <td> <input type='checkbox' name='column[]' value='".mysql_field_name($result, $x)."'>".mysql_field_name($result, $x)." </td> <td> <select name='operator[]'> <option value='='>equals</option> <option value='<>'>does not equal</option> <option value='>'>greater than</option> <option value='<'>less than</option> <option value='>='>greater than or equal to</option> <option value='<='>less than or equal to</option> <option value='LIKE'>is like</option> </select> </td> <td><input type='text' name='criteria[]'></td> </tr>"; } echo " </table> </td> <td valign='top'><input type='submit' value='Process Query' name='submit' class='submit'></td> </tr> </table> </form>"; } else { echo "<b>Fields to edit:</b> "; foreach ($_POST['fields'] as $fields) { echo $fields,", "; } echo "<br><br>"; echo "<b>Columns to query:</b> "; foreach ($_POST['column'] as $columns) { echo $columns," HERE IS THE SPOT, "; } } well, here's my problem, im new to php, i currently working on this mini online shop the picture will explain it well, i've managed to create the receipt per shop but i cant do the receipt of the overall shopping here is my code: <html> <head> <title>My Shop 4</title> <script type="text/javascript"> function gohome() { window.open("receipt.php","_self"); } function changeshop() { window.open("home.html","_self"); } </script> </head> <body> <form action="" method="POST"> <input type="checkbox" name="prod1" id="prod1"\ value=10>Product 1 10.00php<br> <input type="checkbox" name="prod2" id="prod2"\ value=20>Product 2 20.00php<br> <input type="checkbox" name="prod3" id="prod3"\ value=30>Product 3 30.00php<br> <input type="checkbox" name="prod4" id="prod4"\ value=40>Product 4 40.00php<br> <input type="checkbox" name="prod5" id="prod5"\ value=50>Product 5 50.00php<br> <input type="submit" name="submit" id="submit" value="Buy!!"><br> <?php $det = 4; require("../Labphp/lab.php"); shop($det); ?> </form> </body> </html> and here's the php part <?php $total = 0; $total3 = 0; $total4 = 0; $recent ="HAHAHA"; global $total,$total3,$total4,$recent; ?> <?php function shop($num) { $value1 = $_POST['prod1']; $value2 = $_POST['prod2']; $value3 = $_POST['prod3']; $value4 = $_POST['prod4']; $value5 = $_POST['prod5']; $sum=0; $sum = $value1 + $value2 + $value3 + $value4 + $value5; if($sum!=0) { echo "Selected Products<br>"; echo "Product Name       Price<br>"; if($value1==true) { echo "Product 1              10.php<br>"; } if($value2==true) { echo "Product 2              20.php<br>"; } if($value3==true) { echo "Product 3              30.php<br>"; } if($value4==true) { echo "Product 4              40.php<br>"; } if($value5==true) { echo "Product 5              50.php<br>"; } echo "Total                     $sum php<br>"; if($num==4) { $total4=$sum; $recent.="Shop 4                  $total4 php<br>"; } else if($num==3) { $total3=$sum; $recent.="Shop 3                  $total3 php<br>"; } $total = $total4 + $total3; echo "$recent              $total"; echo "<input type='button' name='go' id='go' value='Choose Another Shop' onclick='javascript:changeshop();'>"; echo "<input type='button' name='end' id='end' value='End Shopping' onclick='javascript:gohome();'>"; } } function getshopping() { return $recent; } ?> the receipt code <?php require("../Labphp/lab.php"); ?> <html> <head> <title>Official Receipt</title> </head> <body <?php echo $_REQUEST["'$recent'"]; ?> </body> </html> I had a developer working on stuff for my site and he died before he got to the uploader. I am not a programmer. I can alter a few basic things, but this is beyond me. I found this basic uploader that I could edit the locations, file types, etc. It is missing one area of functionality that I need, the ability to define how many upload fields through a variable (which is set in an earlier form). So for example $fields = "3" then 3 upload fields appear with descriptions set by variables (for examples sake...front and then upload area, back and then upload area, misc. and upload area). I know this might not make a lot of sense. If you need any clarification please contact me. Any help would be much appreciated! So I'm trying to learn PHP so that I can work with the SteamAPI.
I have previous coding experience (C, Java) and I'm uncertian on why my script isn't working.
API: https://github.com/a...teamweb-php-api
Error:
Parse error: syntax error, unexpected '[' in index.php on line 51
Line 51:
$parameters = ['key' => STEAM_WEB_API_KEY];From what I've understood, the script is trying to create an array called "parameters" and inside it's trying to create a variable called "key" which is going to hold the constant "STEAM_WEB_API_KEY". This constant is suppose to be loaded from a file called "steamwebapi_config.php" which looks like the following: <?php /** * Steam Web PHP API */ const STEAM_WEB_API_KEY = 'your steam api key that is given by vavle';I didn't attach my actual key in the script above for obvious reasons. I have no idea how to fix this issue nor what is casuing it. Again, I'm not experienced with PHP and I'd appreciate any help you guys can give me! Thanks to anyone who helps. Hello, I'm new to this forum, and I have just spend half an hour typing out my question as complete as possible, and just before I wanted to hit the "Post" button, I pressed "why not?" out of curiousity @ Read the rules before you post! We will NOT edit/delete your content (why not?)! so I lost everything I wrote. Anyway. I'll shortly retype it all: I'm a Dutch student - therefore my English isn't that good, I'm sorry for that - and for school, I have to make a website. It has to include a CMS system, a search-box, a contactform, Google Analytics and Google Maps. In the meantime, I don't even seem to be able to write 3 php lines properly. When I tried to, and uploaded my work, my site (www.amstel-webdesign.nl) told me: Parse error: syntax error, unexpected T_STRING in /home/amstelwd/domains/amstel-webdesign.nl/public_html/index.php on line 119 Hereunder, please find the source: Code: [Select] <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Amstel webdesign & graphics</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <!-- header start --> <div id="header"> <ul> <li><a href="">Homepage</a></li> <li><a href="">Over ons</a></li> <li><a href="">Webdesign</a></li> <li><a href="">Graphics</a></li> <li><a href="">Prijzen</a></li> <li><a href="">Contact</a></li> </ul> </div> <!-- header end --> <!-- body start --> <div id="body"> <div class="left"> <a href="#" title="Over ons"><img src="images/hobby_profession.png" alt="Onze hobby is ons beroep geworden..." width="780" height="305" border="0" /></a><br class="spacer" /> <br class="spacer" /> <h2><span>Home</span>page</h2><br /> <br /> <p>Is het niet ieders droom om van je hobby je werk te maken? Wij, webdesigners van Amstelland, zijn erin geslaagd die droom waar te maken. Als kleine jongetjes vonden wij het al leuk om met computers te spelen, inmiddels doen wij dat als werk. Maar dat betekent niet dat wij ons werk niet serieus nemen. Juist omdat wij zo van webdesign houden, zullen wij er alles aan doen om ervoor te zorgen dat het u aan niets ontbreekt. Wij zijn toegewijde professionals die plezier hebben in hun werk. En dat merkt u ook! Wij zijn niet vies van zware opdrachten of lastige problemen, we zien het als een uitdaging... </p> <p>Heeft u al een website, dan kunt u deze gratis door ons laten testen. Wij testen op een aantal essentiële onderdelen van uw site. U krijgt snel een kort, duidelijk en uiteraard vrijblijvend rapport, met daarin eventueel te verbeteren punten. Daarna heeft u de mogelijkheid om ons de punten in kwestie te laten verbeteren, en de website te laten onderhouden, tegen een scherp tarief. Heeft u interesse in een dergelijke test, maakt u dan een afspraak met ons. Als u het contactformulier invult, te vinden onder de menuknop <a href="">contact</a>, dan nemen wij zo spoedig mogelijk contact met u op. <br /> </p> </div> <div class="right"> <h2><span>Diensten</span></h2><br /> <ul> <li><a href="#">Webdesign </a></li> <li><a href="#">Consultancy </a></li> <li><a href="#">Onderhoud </a></li> <li><a href="#">CMS </a></li> <li><a href="#">SEO </a></li> <li><a href="#">Webshop ontwikkeling </a></li> <li><a href="#">Contactformulier ontwikkeling </a></li> <li><a href="#">Zoekfunctie ontwikkeling </a></li> <li><a href="#">Google Analytics </a></li> <li><a href="#">Google Maps </a></li> <li><a href="#">Mobiel </a></li> <li><a href="#">Huisstijl ontwikkeling </a></li> <li><a href="#">Drukwerk </a></li> <li><a href="#">Vertalingen </a></li> </ul> <br /><br /> <form method="post" action="#" name="search" class="search"> <label><span>Zoek</span>functie</label> <br class="spacer" /> <input name="search" type="text" id="search" /> <a href="#" title="Advance search">Geavanceerd zoeken</a><input name="" type="image" src="images/search_btn.gif" title="Search" class="searchBtn"/> </form> <form method="post" action="#" name="login" class="login"> <h2><span>Log-</span>in</h2><br class="spacer" /> <label>Naam</label><br class="spacer" /> <input name="name" type="text" id="name" /><br class="spacer" /> <label>Wachtwoord</label><br class="spacer" /> <input name="password" type="password" id="password" /><br class="spacer" /> <input name="" type="image" src="images/login_btn.gif" title="Login" class="loginBtn" /> </form><br class="spacer" /> </div> <br class="spacer" /></div> <!-- body end --> <!-- footer start --> <div id="footer"> <div class="footer"> <div id="nav_left"> <a href="" title="Home">Home</a> <br /> <a href="" title="Over ons">Over ons</a> <br /> <a href="" title="Webdesign">Webdesign</a> <br /> <a href="" title="Graphics">Graphics</a> <br /> <a href="" title="Prijzen">Prijzen</a> <br /> <a href="" title="Contact">Contact</a> <br class="spacer" /> </div> <div id="nav_center"> <a href="">Webdesign</a> <br /> <a href="">Consultancy</a> <br /> <a href="">Onderhoud</a> <br /> <a href="" title="Content Management System">CMS</a> <br /> <a href="" title="Search Engine Optimization / Zoekmachine Optimalisatie">SEO</a> <br /> <a href="">Webshop ontwikkeling</a> </div> <div id="nav_right"> <a href="">Google Analytics</a> <br /> <a href="">Google Maps</a> <br /> <a href="">Mobiel</a> <br /> <a href="">Huisstijl ontwikkeling</a> <br /> <a href="">Drukwerk</a> <br /> <a href="">Vertalingen</a> </div> </div> </div> <!-- footer end --> </body> </html> The php part is marked in red (I hope)... And line 119 is echo ("Amstel_webdesign_graphics" date ("Y")) Could someone please tell me what I'm doing wrong, and what it's all supposed to be? Before I uploaded my index.html with the php lines, my piece was xhtml 1.0 strict and had a valid CSS. I left part of the footer out, so if that created any mistakes (a </div> too many or not enough or such), it probably has nothing to do with the php fail. Thanks so much in advance. Anthony Hi there I'm new in the php coding and I just don't undestand most of all database settings etc... so I have something to do but I don't know exactly how so here is the thing: The disciplines are separated into modules. A module contains lectures and more than 1 group that gets exercises and practical training. The necessary number of the hours of a module is formed of the sum of the hours of lectures, exercises and practical training, multiplied by the numbers of the groups. The site has to give the possibility of: - Writing into new modules and lecturers. - Defining the number of groups (lectures, exercises, practical training) for a module. - Appropriating of groups and lecturers. - Visualizing the list of modules/lecturers. if you can help with advices or whatever you can I'll be very thankfull I get to errors below and cannot figure out what im doign wrong i've tryed diffrent ways and have even rewritten this couple times (#1error) not sure how to re query and echo out the array?? (#2error) gives me error on line 14 if i echo anything past (echo $row['name']."|user1:". $row['user1']. "|user2:". $row['user2']. ->this Code: [Select] <?php $conn = mysql_connect("localhost", "root", ""); if (!$conn) { echo "Unable to connect to DB: " . mysql_error(); } if (!mysql_select_db("register_db")) { echo "Unable to select mydbname: " . mysql_error(); exit; } $result = mysql_query("SELECT * FROM register_vote WHERE name = '{$_POST['user']}'"); if (!$result) { echo "Could not successfully run query ($sql) from DB: " . mysql_error(); exit; } =========================(#1error)========================================== //THIS IS THE CODE I'M HAVING ISSUES WITH if (mysql_num_rows($result) == 0) { mysql_query("INSERT INTO register_vote (name) VALUES ('$_POST[user]')"); //need it to the query new results after insert //then // echo $row['name']."|user1:". $row['user1']. "|user2:". $row['user2']. "|user3:". $row['user3']; }================================================= (#2error)=================================== while ($row = mysql_fetch_array($result)) { echo $row['name']."|user1:". $row['user1']. "|user2:". $row['user2']. "|user3:". $row['user3']; } //when I put anything past $row['user2']. it gives me error on line 14 mysql_free_result($result); ?> Hi. I'm currently taking a class in PhP and I'm having issues getting my code to work. I "borrowed" part of the code from elsewhere (but I fully understand each line - which is really the point of learning) I'm hoping a second set of eyes might help on what's wrong: I'm running Wamp Server v2.0 on my local PC to test the scripts... I'm sure I'm probably going to have more then just this error with the script, but it's hard to move forward when you're stuck spinning your wheels. Any help would be greatly appreciated... and any suggestions as to a better way to approach this would be welcome as well. I am here to learn after all Here's the error I'm getting: Notice: Undefined variable: fname in C:\Web Server\wamp\www\daystoxmas.php on line 8 Please return to the main page and enter your First Name. Here's the HTML Code: <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/ xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Days to Christmas Form</title> </head> <body> <div><p><h1>Days to Christmas Form</h1></p> <p>- Programmed by: Michael Custance</p> <form action="daystoxmas.php" method="post"> <p>First Name: </select><input type="text" name="fname" size="20" /></p> <p>Last Name: </select><input type="text" name="lname" size="20" /></p> <p>E-mail Address: <input type="text" name="email" size=20 /></p> For Christmas gift ideas, click here! <input type="submit" name="Submit" value="Christmas Gift Page" /> </form> </body> </html> And here's the PhP Form: <HTML> <HEAD> <TITLE>daystoxmas.php</TITLE></HEAD> <BODY> <?php if ($fname) { print ("Good "); if (date("A") == "AM") { print ("morning, "); } elseif ( (date("H") >= 12 ) and (date("H") < 18) ) { print ("afternoon, "); } else { print ("evening, "); } print ("$FirstName<P>"); $Christmas = mktime(0, 0, 0, 12, 25, date('Y')); $today = mktime(); $seconds_to_christmas = $Christmas - $today; $days_to_christmas = $seconds_to_christmas / 86400; $days_to_christmas = floor($days_to_christmas); $temp_remainder = $seconds_to_christmas - ($days_to_christmas * 86400); $hours = floor($temp_remainder / 3600); $temp_remainder = $temp_remainder - ($hours * 3600); $minutes = round($temp_remainder / 60, 0); echo '<p>There is ' . $days_to_christmas . ' days and ' . $hours . ' hours and ' . $minutes . ' minutes until Christmas</p>'; } else { print ("Please return to the main page and enter your First Name."); } ?> </BODY> </HTML> Ok so heres the deal, my friend wrote this for me, hes currently unavailable and i messed it up a bit. http://pastebin.com/k937xDve < there is the code. all i did is add the Code: [Select] target="name" onclick="window.open('http://www.web-hosting-service.org/green-certified.php?greensite=.$domain.','name','height=255,width=250,toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no'); return false;" bit. and now i get the error Parse error: syntax error, unexpected T_STRING in seal-generator.php Ok, I am sure this is really simple for all of you, but I have very little experience with php. I haven't sat down to learn php yet, but I will when I have more free time. In the meantime I have the following issue: The site is http://astoryaday.fromyay.com/ I have all the stories in the /stories/ directory, all named 20110504.html, 201105005.html, etc. Every day I write another story, I name it following that pattern, and drop it into the /stories/ folder. I only want the newest story displayed on the page. So I wrote a little script that is: Code: [Select] <?php $files = glob("stories/*.html"); sort($files); $newest = array_pop($files); include($newest); ?> Now, what I want to do, is in the footer, put an Archive that will look like this: -2012 --January ---03 ---02 ---01 -2011 --December ---31 ---30 And upon clicking on the dates, the story from that day will replace the story that is currently included. Any help of how to get this done would be appreciated! Thanks Hi all i have a silly noob question.... When i directly query my database with the following i get the exact result i want....... Code: [Select] SELECT * FROM posts WHERE postTopic=3 AND postSubject=business; However when i try this using the following PHP....... $sql = "SELECT * FROM posts WHERE postTopic =" . mysql_real_escape_string($_GET['id']) . "AND postSubject='" . $_SESSION[forum] . "'"; I get no result I also get the correct results from $sql = "SELECT * FROM posts WHERE postTopic =" . mysql_real_escape_string($_GET['id']) . "; and $sql = "SELECT * FROM posts WHERE postSubject='" . $_SESSION[forum] . "'"; mysql_real_escape_string($_GET['id']) is an integer and $_SESSION[forum] is a string. I know this has something to do with the manner in which the query is passed with the AND and the string but i can't for the life of my work out where i am going wrong. Thanks for any help. Hi guys! Total noob here that needs a bit of help creating a form. I have gotten this piece of code and want people to optin with Name and email. Let me send the code first: Request for PHP language: <?php $apiUrl = "https://udimi.com/api/affgen/addref"; $headers = [ "Content-Type: application/json", "Auth: MY AUTH CODE HERE" ]; $referral = [ 'fullname' => 'Referral Fullname', 'email' => 'refemail@domain.com' ]; $curl = curl_init(); curl_setopt_array($curl, [ CURLOPT_URL => $apiUrl, CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => "", CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => false, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => "POST", CURLOPT_POSTFIELDS => json_encode($referral), CURLOPT_HTTPHEADER => $headers ]); $response = curl_exec($curl); $err = curl_error($curl); curl_close($curl); if ($err) { echo "cURL Error #:" . $err; } else { echo $response; } Success JSON response (HTTP status code: 200): {"error": false} Failed JSON response (HTTP status code: 200): {"error": "Pass identity verification and earn a commission as Udimi affiliate."} POST fields: fullname: required, 2-25 chars, only English letters. email: required So I figured I need to create a html file with a simple form, so I created this: <fieldset> <legend>Form</legend> <form action="test.php" method="post"> <label>Full Name: </label><input type="text" name="fullname" /><br /> <label>Email: </label><input type="text" name="email" /><br /> <input type="submit" name="submit" value="submit" /> </form> </fieldset> The problem is that I got it populate something when entering the form but the name was "Referral Fullname" as the code and the email was "refemail..." as the code. It did not grab my input. Any pointers here? Should I approach it in another way? Long story short i'm paginating database results. So pages = results / res-per-page-limit but 28 / 10 will be 2.8 should i use round() or ceil()? Basically I am trying to make a list of items which I have put into an sql database. When I click on an item in the list, I want a "generic" page loaded, with the items description. Im having alot of trouble with getting this generic page to work. Heres what Ive done so far. The page with shows the list http://pastebin.com/PE8FkyYQ http://pastebin.com/GiCpV5AH The generic page with the items description. http://pastebin.com/HFnSfqN4 http://pastebin.com/C0zsHpZY If anyone can help me solve this problem, ill be greatly in there debt! I have a website that I have curled some data from and gotten the data I want. It is one large array. The variable is called $ten_pireps. For clarity I am only posting the first 8 keys=>value pairs. The array repeats the info every 8 keys. ending with key [79]. Array ( => ET20029 [1] => EAL391 [2] => ESKN [3] => EETN [4] => E35 [5] => 0.8 [6] => 284 [7] => 01/02/2011 I need to iterate through this 79 key array and place keys thru [7] into another variable array called $flightinfo1, keys [8] thru [15] into $flightinfo2, etc..... finish with the final array $flightinfo10. Secondly, I am trying to name the keys of the new 10 smaller seperate arrays with key names [Flight_Num] [Call_Sign] [Dep_Icao] [Arr_Icao] [Equip] [Flt_Time] [Flt_Distance] [Date] being the same for each array. Ultimately I will be inserting this into a db. I suck with arrays, and have tried to modify code snippets and have had no success. Here is something I was trying but just could echo anything out that made sense. foreach ($ten_pireps as $key=>$value) { } for ($i=0,$j=1;$i<count($ten_pireps); $i+=8,$j++) { $flight="flightinfo"; $flightsql="$flight$j"; // create new variable name array as it iterates $flightsql[Flight_Num] = $ten_pireps[$i]; $flightsql[Call_Sign] = $ten_pireps[$i+1]; $flightsql[Dep_Icao] = $ten_pireps[$i+2]; $flightsql[Arr_Icao] = $ten_pireps[$i+3]; $flightsql[Equip] = $ten_pireps[$i+4]; $flightsql[Flt_Time] = $ten_pireps[$i+5]; $flightsql[Flt_Distance] = $ten_pireps[$i+6]; $flightsql[Date] = $ten_pireps[$i+7]; // unfinished cause it is wrong!!!! } Thanks for the read - Nacman Hey, I have made a audio button in dreamweaver and copied the code into my php panel: <script language="JavaScript" src="http://www.MYWEBSITE.com/myname/audio/audio-player.js"></script> <object type="application/x-shockwave-flash" data="http://www.MYWEBSITE.com/media_folder/audio/player.swf" id="audioplayer1" height="24" width="290"> <param name="movie" value="http://www.MYWEBSITE.com/media_folder/audio/player.swf"> <param name="FlashVars" value="playerID=audioplayer1&soundFile=http://www.MYWEBSITE.com/media_folder/audio/Reconstructed Ancient Egyptian Melody.mp3"> <param name="quality" value="high"> <param name="menu" value="false"> <param name="wmode" value="transparent"> </object> However once I press save, all that is saved is: <script language="JavaScript" src="http://www.MYWEBSITE.com/myname/audio/audio-player.js"></script> <object type="application/x-shockwave-flash" data="http://www.MYWEBSITE.com/media_folder/audio/player.swf" id="audioplayer1" height="24" width="290"> <param name="movie" value="http://www.MYWEBSITE.com/media_folder/audio/player.swf"> The audio button works however because the code which includes the mp3 file never saves, it can never find the audio file. Can anyone tell me why the audio file part of the code doesn't save? Thanks. |