PHP - Dynamically Reading And Displaying Values
Let's say I have a script that updates the database every 5 minutes. Or fwrites to a text file at an interval.
How do I say create a dynamic textbook or label that displays this information and automatically UPDATES on the page without the user clicking on REFRESH? Similar Tutorials
Table Issue - Multiple Location Values For User Pushes Values Out Of Row Instead Of Wrapping In Cell
what follows is a simplified version of what i'm attempting to do. say i have a mysql table called 'pages', that looks roughly like this: Code: [Select] id parent label 1 0 home 2 0 about 3 0 events 4 2 history 5 2 philosophy 6 3 past-events 7 3 future-events 8 6 past-event-gallery which uses the parent key as a self-referencing index. items with parent=0 don't have a parent - all other items refer to rows in the same table. so, 'about' has 2 children: 'history' and 'philosophy'. this can extend an unlimited number of levels in depth. e.g., 'past-event-gallery' has a parent of 'past-events' which has a parent of 'events'. building it out is pretty straightforward - start with all rows that have a parent of 0, then recurse... Code: [Select] select id, label from pages where parent=0 // grab the id... select id, label from pages where where parent={$id} etc. which works (for example) to build out a uri for an <a> tag's href attribute. the problem arises when trying to go backwards... i'm trying to get back the id of the row from that example uri... so if the output was 'events/past-events/past-event-gallery', i'm exploding on slashes to get the component parts, and want to walk it back to get the id of the row. if the label keys were unique, it'd be simple enough... select id from pages where label={$label} but labels might be duplicated. for example, 'past-events' might have a child called 'gallery', but it might be possible that 'about' also has a child called 'gallery', etc. it might even occur several levels deep, so i need to walk it backwards until i've determined the correct id from the component parts of the URI. my initial thought was to run from left-to-right, something like: Code: [Select] while(count($parts) > 0){ $component = array_shift($parts); $result = mysql_query("select id from pages where label='{$component}'"); // this is where i lose it... maybe create a temp table from the results and continue...? } or maybe from right-to-left... Code: [Select] while(count($parts) > 0){ $component = array_pop($parts); $result = mysql_query("select id from pages where label='{$component}'"); $row_count = mysql_num_rows($result); switch($row_count){ case 1 : // this is the only one with that label, so return the ID and be done break; case 0 : // no labels match, so return a 404 or missing item or something and be done break; default : // if there are more than 1 matching labels, figure out which one - here is where i get lost on this approach... break; } } also considered a self-returning function for the second (right-to-left) idea, but didn't get far with it. any ideas? i could be (probably am) totally off on both approaches mentioned, and there might be a much easier way to do this. i'd be happy to hear any suggestions... tyia Hello again. I'm trying to load data from a Facebook Share Data XML file and then displaying them in a WordPress plugin. Here's my code so far: // Fetch Share Count Data function fb_button () { $fbshareUrl = urlencode(get_permalink($post->ID)); $fbshareTitle = urlencode($post->post_title); $fbLinkStats = simplexml_load_file('http://api.facebook.com/restserver.php?method=links.getStats&urls='.$shareUrl); $fb_params = '?u=' . $fbshareUrl . '&t=' . $fbshareTitle . '' ; // Vertical Facebook Button $fb_share = ' <div class="fsbsharer" id="fb"> <a href="http://www.facebook.com/sharer.php' . $fb_params . '" class="facebookShare"> <span class="fb_share_size_Small fb_share_count_wrapper"> <span></span> <span class="fb_share_count_nub_top "></span> <span class="fb_share_count fb_share_count_top"> <div class="fb_share_count_inner"> '. $fbLinkStats->link_stat->total_count .' </div> </div> <span style="cursor:pointer;" class="FBConnectButton FBConnectButton_Small"><span class="FBConnectButton_Text">Share</span></span> </a> </div> '; echo $fb_share; } This code works for everything except the title and the share count. I can fix the title myself but the share count isn't working. When I use this in plain HTML: <?php echo $fbLinkStats->link_stat->total_count.''; ?> it works fine, but when I combine it all into another function to echo, it no longer works properly. Thanks. So, I'm trying to get this read my text document "news.txt" and display the contents. My code: Code: [Select] div.newscontent{ padding:0px; margin-top:60px; margin-bottom:0px; margin-left:400px; margin-right:0px; position:absolute; width:457px; height:330px; text-align:center; color:#FFFFFF; } Code: [Select] <div class='newscontent'> <?PHP $filename = "news.txt"; $arr = file($filename); foreach($arr as $line){ print $line . "<br/>"; } ?> </div> This is the output I get: Code: [Select] "; } ?> Whats wrong? Hi! So I have got some code that looks like this: Code: [Select] if (isset($_GET['view_log'])) { // show content (text from db) } When I click the button named "view_log" everything displays just fine, however I would like to be able to click the button again and make the content disappear. Is this possible using only PHP?? Thanks for the help!:) It is greatly appreciated! Hi all I have a form with a few textareas and a bunch of input fields. The input fields are dynamically created from querying a country table. $query = $DB->query("SELECT country_code, country_id, IF(country_code = '".$country_code."', '', '') AS sel FROM countries WHERE site = 'test' ORDER BY country_name ASC"); foreach ($query->result as $row) { $options .= '<label>' . 'Phrase for ' . $this->settings['countries'][$row['country_code']] . '</label>' . '<br />'; $options .= '<input style="width: 100%; height: 5%;" id="country_data" type="text" name="' . $row['country_id'] . '" />' . '<br /><br />'; $options .= '<input type="hidden" name="country_id" id="country_id" value="' . $row['country_id'] . '" />'; } This is fine and outputs all the input fields I need. The problem comes when I need to get the value of each field input field and pass it into a query. The 'value' field of the inputs are numbers, such as 68, 70, 124, 108 etc so I can't get them in a for loop etc What's the easiest way to get all of these input field values? Can I use $_POST? my name is fairooj and ama new to php and jquery. i have a proplam. i want your help.
<script type="text/javascript"> var count = 0; $(function(){ $('p#add_field').click(function(){ count += 1; $('#container').append( '<strong>Link #' + count + '</strong><br />' + '<input id="field_' + count + '" name="fields[]' + '" type="text" />' + '<input id="code_' + count + '" name="code[]' + '" type="text" /><br />' ); }); }); </script> hello, i'm actually doing a javascript here to create dynamic textboxes when a button is clicked. now my problem is, how to get all the values from these textboxes and save these values altogether in a column on the table.. i know few php coding methods like $_POST in handling values from txtboxes and saving it to database but it doesn't include working with javascript and dynamic textboxes.. and i'm actually doubtful if this is possible..so any help from you guys i would deeply appreciate. heres my code: Code: [Select] <html> <head> <script type="text/JavaScript"> function AddTextBox() { document.getElementById('container').innerHTML+='<input type="text" name="block"><br>'; } </script> </head> <body> <input type="text" name="block"> <div id="container"></div> <br> <button onclick="AddTextBox();">Add another textbox</button> </body> </html> hey i am using a MySql database and i need to create a dynamic HTML table with one of its columns as checkboxes.so i have to create multiple checkboxes.but these checkbox values are to be stored in a mysql table and then later retrieved when form reloads.and depending on previous state when form was submitted, the newly created checkboxes have to be checked in the same manner.so how do i store multiple checkbox values in my table and also how do i retrieve them? please help. What I have is a page with a list of cars, each with a checkbox next to them. Code: [Select] <?php $sth = null; $count = 0; $sth = $dbh->prepare("SELECT * FROM garage WHERE warehouse_id = ? ORDER BY car_name ASC"); $sth->execute(array($_POST['ware_id'])); echo "<table>"; echo "<tr>"; echo '<td>Choose Vehicles:</td>'; echo "</tr>"; echo "<tr>"; echo "<td>"; echo "<form action='warehouse_ship_3.php' method='POST'>"; while($row = $sth->fetch()){ echo "<input type='checkbox' name='cars' value='".$row['uci']."' /> ID: ".$row['uci'].", ".$row['car_year']." ".$row['car_name']."<br />"; } echo "<input type='hidden' name='ware_id' value='".$_POST['ware_id']."' />"; echo "<hr />"; echo '<div class="center"><input class="myButton" type="submit" name="submit" value="Next" /></div></form>'; echo "</td>"; echo "</tr>"; echo "</table>"; ?> That works fine. What I'm trying to do with this second page, is select all the car's info from a table called "garage" which stores data for all the cars (car name, year, etc) and display it. UCI stands for Unique car id, every car has a different id. It works when the user only selects one car on the previous page, but if they select two or more cars, only the car with the highest UCI number shows up. How would I work it to display info on every car that they selected? Code: [Select] <?php if(empty($_POST['cars'])) { echo("You didn't select any cars."); } else { $sth = $dbh->prepare("SELECT * FROM `garage` WHERE `uci` = ?"); $sth->execute(array($_POST['cars'])); while($cars = $sth->fetch()){ echo" ".$cars['uci'].", ".$cars['car_year']." ".$cars['car_name']." "; } } ?> Hi im not sure if this can be done or not but im trying to do a site without using mysql and i want to be able to compare 3 values and depending on the values have them aranged lowest to highest... for example: Apple = 8 Pear = 3 Bannana = 5 so the results would be displayed like... Pear with a total of 3 bannana with a total of 5 Apple with a total of 8 Is this possible using just PHP or will i need to use Mysql as well... Thank you Chris I am trying to give role based access here. I want to display the pages which user has access in checkbox format. Here is my code $sql = "SELECT p.page_id AS pid, p.page, p.href, ra.pages AS rpage FROM pages p INNER JOIN role_access ra WHERE p.page_id IN (ra.page) AND ra.role=1"; $query = mysqli_query($con, $sql) or die(mysqli_error($con)); $checked_arr = array(); while($row = mysqli_fetch_array($query)) { $checked_arr = explode(",",$row['rpage']); foreach ($checked_arr as $page) { echo "<br/><input type='checkbox' name=\"pages[]\" value='$page' />$page<br>"; } My tables are like this ROLE CREATE TABLE `role` ( `rid` int(5) NOT NULL, `role_name` varchar(50) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `role` (`rid`, `role_name`) VALUES (1, 'Admin'), (2, 'Others'); ALTER TABLE `role` ADD PRIMARY KEY (`rid`); ROLE-ACCESS CREATE TABLE `role_access` ( `id` int(10) NOT NULL, `page` varchar(160) NOT NULL, `role` int(7) NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `role_access` (`id`, `page`, `role`) VALUES (1, '1,2,3,4,5', 1), (2, '2,4,5', 2); ALTER TABLE `role_access` ADD PRIMARY KEY (`id`); PAGES CREATE TABLE `pages` ( `page_id` int(11) NOT NULL, `code` varchar(10) NOT NULL, `page` varchar(100) NOT NULL, `href` varchar(255) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO `pages` (`page_id`, `code`, `page`, `href`) VALUES (1, 'Patient', 'Registration', '/patient_registration.php'), (2, 'Patient', 'List', '/patient_list.php'), (3, 'Patient', 'Edit', '/edit_patient.php'), (4, 'Patient', 'Export', '/export_patient.php'), (5, 'Patient', 'MRD', '/patient_MRD.php'); ALTER TABLE `pages` ADD PRIMARY KEY (`page_id`);
In above query i get result like this
But required result is
if i change checkbox display like while($row = mysqli_fetch_array($query)) { $checked_arr = explode(",",$row['rpage']); $pname = $row['page']; foreach ($checked_arr as $page) { echo "<br/><input type='checkbox' name=\"pages[]\" value='$page' />$pname<br>"; } } i get result
How to get the names for that file.
Hi, I'm inserting hours and minutes per user into a database where they have their own fields. (userid, hours, mins) I've a small issue when displaying the data. When I run my query I sum the total hours and minutes per user which results in data such as the following userid1 - 2 hours 15 mins userid2 - 1 hour 100 mins The query orders by hours and then mins desc When I'm displaying the data (as I'm looping through the results array) I perform a calculation to convert the mins to hours so it now reads userid1 - 2 hours 15 mins userid2 - 2 hours 40 mins so the webpage displays userid1 first when i want userid2 to be the first record displayed (Hours desc) Can anyone recommend a solution to this ? Will I need to create another table and update it as hours and minutes are being entered and display results from that table instead ? Can I order the data after I carry out the mins to hours calculation ? many thanks in advance for any suggestions.... tmfl Dear All Members here is my table data.. (4 Columns/1row in mysql table)
id order_no order_date miles How to split(miles) single column into (state, miles) two columns and output like following 5 columns /4rows in mysql using php code.
(5 Columns in mysql table) id order_no order_date state miles 310 001 02-15-2020 MI 108.53 310 001 02-15-2020 Oh 194.57 310 001 02-15-2020 PA 182.22
310 001 02-15-2020 WA 238.57 ------------------my php code -----------
<?php
if(isset($_POST["add"]))
$miles = explode("\r\n", $_POST["miles"]);
$query = $dbh->prepare($sql);
$lastInsertId = $dbh->lastInsertId(); if($query->execute()) {
$sql = "update tis_invoice set flag='1' where order_no=:order_no"; $query->execute();
} ----------------- my form code ------------------
<?php -- Can any one help how to correct my code..present nothing inserted on table
Thank You Edited February 8, 2020 by karthicbabuHi, My company has 240+ locations and as such some users (general managers) cover multiple sites. When I run a query to pull user information, when the user has multiple sites to his or her name, its adds the second / third sites to the next columns, rather than wrapping it inside the same table cell. It also works the opposite way, if a piece of data is missing in the database and is blank, its pull the following columns in. Both cases mess up the table and formatting. I'm extremely new to any kind of programming and maybe this isn't the forum for this question but figured I'd give it a chance since I'm stuck. The HTML/PHP code is below: <table id="datatables-column-search-select-inputs" class="table table-striped" style="width:100%"> <thead> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> <th>Actions</th> </tr> </thead> <tbody> <?php //QUERY TO SELECT ALL USERS FROM DATABASE $query = "SELECT * FROM users"; $select_users = mysqli_query($connection,$query);
// SET VARIABLE TO ARRAY FROM QUERY while($row = mysqli_fetch_assoc($select_users)) { $user_id = $row['user_id']; $user_firstname = $row['user_firstname']; $user_lastname = $row['user_lastname']; $username = $row['username']; $user_phone = $row['user_phone']; $user_image = $row['user_image']; $user_title_id = $row['user_title_id']; $user_role_id = $row['user_role_id'];
// POPULATES DATA INTO THE TABLE echo "<tr>"; echo "<td>{$user_id}</td>"; echo "<td>{$user_firstname}</td>"; echo "<td>{$user_lastname}</td>"; echo "<td>{$username}</td>"; echo "<td>{$user_phone}</td>";
//PULL SITE STATUS BASED ON SITE STATUS ID $query = "SELECT * FROM sites WHERE site_manager_id = {$user_id} "; $select_site = mysqli_query($connection, $query); while($row = mysqli_fetch_assoc($select_site)) { $site_name = $row['site_name']; echo "<td>{$site_name}</td>"; } echo "<td>{$user_title_id}</td>"; echo "<td>{$user_role_id}</td>"; echo "<td class='table-action'> <a href='#'><i class='align-middle' data-feather='edit-2'></i></a> <a href='#'><i class='align-middle' data-feather='trash'></i></a> </td>"; //echo "<td><a href='users.php?source=edit_user&p_id={$user_id}'>Edit</a></td>"; echo "</tr>"; } ?>
<tr> <td>ID</td> <td>FirstName</td> <td>LastName</td> <td>Username</td> <td>Phone #</td> <td>Location</td> <td>Title</td> <td>Role</td> <td class="table-action"> <a href="#"><i class="align-middle" data-feather="edit-2"></i></a> <a href="#"><i class="align-middle" data-feather="trash"></i></a> </td> </tr> </tbody> <tfoot> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> </tr> </tfoot> </table>
Hi all, I'm a first time poster here and I would really appreciate some guidance with my latest php challenge! I've spent the entire day googling and reading and to be honest I think I'm really over my head and need the assistance of someone experienced to advise the best way to go! I have a multi dimensional array that looks like (see below); the array is created by CodeIgniter's database library (the rows returned from a select query) but I think this is a generic PHP question as opposed to having anything to do with CI because it related to working with arrays. I'm wondering how I might go about searching the array below for the key problem_id and a value equal to a variable which I would provide. Then, when it finds an array with a the matching key and variable, it outputs the other values in that part of the array too. For example, using the sample data below. How would you recommend that I search the array for all the arrays that have the key problem_id and the value 3 and then have it output the value of the key problem_update_date and the value of the key problem_update_text. Then keep searching to find the next occurrence? Thanks in advance, as above, I've been searching really hard for the answer and believe i'm over my head! Output of print_r($updates); CI_DB_mysql_result Object ( [conn_id] => Resource id #30 [result_id] => Resource id #35 [result_array] => Array ( ) [result_object] => Array ( ) [current_row] => 0 [num_rows] => 5 [row_data] => ) Output of print_r($updates->result_array()); Array ( [0] => Array ( [problem_update_id] => 1 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Some details about a paricular issue [problem_update_active] => 1 ) [1] => Array ( [problem_update_id] => 4 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Another update about the problem with an ID of 3 [problem_update_active] => 1 ) [2] => Array ( [problem_update_id] => 5 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of four [problem_update_active] => 1 ) [3] => Array ( [problem_update_id] => 6 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of 6 [problem_update_active] => 1 ) [4] => Array ( [problem_update_id] => 7 [problem_id] => 3 [problem_update_date] => 2010-10-12 [problem_update_text] => Some new update about the problem with the ID of 3 [problem_update_active] => 1 ) ) Hi all, Just curious why this works: Code: [Select] while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){ $import="INSERT into $prodtblname ($csvheaders1) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]')"; } And this does not: $headdata_1 = "'$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]'"; while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){ $import="INSERT into $prodtblname ($csvheaders1) values($headdata_1)"; }it puts $data[#'s] in the database fields instead of the actual data that '$data[0]','$data[1]'... relates to. I wrote a script to create the values in $headdata_1 based on the number of headers in $csvheaders1 but can't seem to get it working in the sql statement. Thanks Hello, I'm trying to read some XML by name this is the XML: Code: [Select] <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <imgdir name="01040000.img"> <imgdir name="info"> <canvas name="icon" width="29" height="30" basedata="iVBORw0KGgoAAAANSUhEUgAAAB0AAAAeCAYAAADQBxWhAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAMuSURBVEhLlZcBlatADEWxUAu1gAUs1AIWsIAFLGChFmphLXwL83ND3jQwlO5yTg6FmcnNSzLDbtf97io27Zv9ztOHWY3zZezKOHSl7/ud8Y6x1/IxoK+BOGwd+zIN99LfN4dnQGAVuG5zmD8Nt7I87u6D55SdU3jh2hZuwPK6lfJvKq9wmkH/nhtId+bPBvtZRgeOva219WQgZaEB++DjfqtQHArs9wjCnVkgCoZ1QIGhEuBgfvyyoJlPgKG6gn1AwKo0FjjcfisIqXOwAW83MysLqZ0MyD0r9Wy9a/6GKloBH7YYZx4plwUlqGBE70CZgVGaU4xifJ+pdZWkRw0AlGhx+JwDHmnNsN7GZahVioFLsac66ptTvKXFjNr0/bB1LvWxptqpCVUERaAC4hgo5kAbVxdL7THFNSUZiuPF1KvW+TdjlAKHgAVFicCoJtVqLvf93kZbWngxPMaqVGpwzsLcaAIKChgYUHxUxWquyCTzleK6TaZp9kUMKEJg7jwiBahtIZVZrXwo3Vp3VEobOyxDmQSw7rc4KDwjEUhOsdTiY56X6ktwZSKfED4Rk1Lvutir+XTxIy8aqnZudLHv14BmMM15PBxc6bI+a4SLPb/Mfsxstt95xhjDprCH3TGeee/1XNed2jOoR5ehcpDBGX4FPkJzyZrUCkp6z5RK7TelW9bWRm1z9qqeiupuCzF92vR505fm7MDQO5zj75jiBiqYmsj3KJ+naCR9VThVCEDj3POW4FlQ+fQT7qqRmMgiTpLnNOzA+qThmDHN4aSabe9iOnGkUh181rnevdlwxB4kZXIodfrQa85RtdQefF7+2eIKstJcP4BSmefxTor9UIk0f/0DKSb4YlSycPCvzvuPMaLXYc88zdV81fjP0FwrAcdxLJhvB4NltfzOSinHX6A7lR61qcxAg9reP1d7Udvv9VTU27e1gfaf1CrdufGimVhj294Dbq5ayw9AOx072a621FSW925AR7vb8dwBb8CeXprnuIXseTazE3BnzX7NezZ8EOQl1OsVRmRMxrLC4++r/2/wMYTCj+kl34CZICMlR5Oj4/u8ThD8NSn9D9wL1z9uxdBdAAAAAElFTkSuQmCC"> <vector name="origin" x="-2" y="30"/> </canvas> <canvas name="iconRaw" width="29" height="29" basedata="iVBORw0KGgoAAAANSUhEUgAAAB0AAAAdCAYAAABWk2cPAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAL4SURBVEhLlZYBtYMwDEVnAQuzgAUsYAELWMACFrAwC7MwC99Cf27o6wJ0sO2cHAZNc/PStHC7ffdL5nZl30X64HUIPg+3NHS31LbtxnjG2HP+mNBlIg5bhjaN3T219zVgDQisAJfVB/+xa9Lc3z0G96E6VXjit05cgenZpPQ3pmcOGkF/jxWkK/6TwV7z4MChtbk2nwqEKhzAPtjfmwIloMB+zUl4MEtEyTAPKDBUAuwsjv8safxJMKsuYB8QsCjNExxu/5WE1DnYgE1jZstCaUcDco1KvVrvNX9Dla2AvU0mmGfKz5ISVDCyd6DMwCiNJUYxsWtqXSXlUQMAJVsCPqYMz2WNsNbGZahViYFLsZc6r28s8VoWM9ambbu1c1kfa6qNmqyKpEhUQAIDxRxo4+piqd2XuJQkQgk8m3qtdfzPGEtBQMCCokRgVFNqNZfHfm+jtSw86PqhKJUagjMxNpqAggIGBpQYRbGaK1cSf5W4bJNxnHwSA8oQmAfPmQLUtpDKqFYxVG7N2yuljR0WoTgBLPstHxRekZxILLHUEmOa5hJLcFUinhDuiEmpd13eq/F08SMvN1Tp3NzFvl8zNIJpzv3h4Ern5VEynO3+afYyM2+/co8xho3Zerti3PPc13NZNmprUM8uQhUggiP8DLyHxiU7lFZQyltTKrVXSteqLQe1h7NX66ms7jYR06tNrze9aWoHhp4RnHj7Eh+ggqmJfI/yesqNpLcKpwoJaJxr3BLcC6qYfsKdNRKOTOIkeYzdBqxXGoEZkw8n1WR7F9OJI5Xq4FrnevdGIxB7kJIpoNTpRS+fvWqp3cU8/WxxBVFpXD+AUhn9eCbFfqjkMl9+IGUHn4xKJnb+1nl/jJG9Dnv85Ct/rfHP0LhWAg7DkDDfDgaLavkflbIcv0A3Kj1rUxmBqkZN7cnaXq+nsl7frXVoTa3KHRvvU9duTiatzQlQ/pu1ZZ4s7t2voGRL8+y30If6HPZr3LPfAIuCX5wryV1+1QP6B07yxunYFCcQAAAAAElFTkSuQmCC"> <vector name="origin" x="-2" y="30"/> </canvas> <string name="islot" value="Ma"/> <string name="vslot" value="Ma"/> <int name="reqJob" value="1"/> <int name="reqLevel" value="40"/> <int name="reqSTR" value="130"/> <int name="reqDEX" value="0"/> <int name="reqINT" value="0"/> <int name="reqLUK" value="0"/> <int name="incDEX" value="3"/> <int name="incMMP" value="10"/> <int name="incPDD" value="45"/> <int name="tuc" value="7"/> <int name="price" value="6700"/> <int name="cash" value="0"/> </imgdir> Say I want to get reqJob and print it onto the page. Also I would need to get the BaseData of the iconRaw canvas. how can I read a url coming from another site by header('Location:') command PHP 5.3.8 XAMPP on Windows XP I have an XML file that manages the input to an mp3 player on this page http://www.jimslounge.com/segovia/ The structure looks like this Code: [Select] <content> <auto_play>yes</auto_play> <loop>yes</loop> <volume>60</volume> <artist> <song_title><![CDATA[Bach - Suite No. 3 - Allemande]]></song_title> <artist_name><![CDATA[Andre Segovia]]></artist_name> <image_path>load/images/segovia.jpg</image_path> <mp3_path>load/songs/Bach - Suite No. 3 (for solo cello, arr. Duarte)- Allemande.mp3</mp3_path> <url target="_blank" open="yes">http://en.wikipedia.org/wiki/Andr%C3%A9s_Segovia</url> </artist> <artist> ... with <artist> being the repeating element I want to be able to read and eventually write to If I run this Code: [Select] $xml = simplexml_load_file("load.xml"); var_dump($xml); I get this object(SimpleXMLElement)#1 (4) { ["auto_play"]=> string(3) "yes" ["loop"]=> string(3) "yes" ["volume"]=> string(2) "60" ["artist"]=> array(22) { => object(SimpleXMLElement)#2 (5) { ["song_title"]=> object(SimpleXMLElement)#24 (0) { } ["artist_name"]=> object(SimpleXMLElement)#25 (0) { } ["image_path"]=> string(23) "load/images/segovia.jpg" ["mp3_path"]=> string(74) "load/songs/Bach - Suite No. 3 (for solo cello, arr. Duarte)- Allemande.mp3" ... [/color] which is overwhelming This cleans it up but doesn't give me the artist name and song name I'm looking for. Code: [Select] $xml = simplexml_load_file("load.xml"); echo $xml->getName() . "<br />"; foreach($xml->children() as $child) { echo $child->getName() . ": " . $child . "<br />"; } The Output: content auto_play: yes loop: yes volume: 60 artist: artist: artist: My experience with simplexml only goes back a couple of hours so I'm pretty inept at this point. Any help will be greatly appreciated. I just can't wrap my head around it, but I am trying to integrate weather into my website using NOAA. 1. Here is the NOAA page: http://forecast.weather.gov/MapClick.php?CityName=Mio&state=MI&site=APX&lat=44.663&lon=-84.1446 2. Here is the XML to that page: http://forecast.weather.gov/MapClick.php?lat=44.66300&lon=-84.14460&FcstType=dwml Now what I want to do is to have PHP on my website that reads the XML from the NOAA site and create the "Forecast At A Glance". Possible or too challenging? |