PHP - Trouble Getting Single Value From Array
Hi, learning as I go here, and I appreciate the help in advance ..
I have some working php code that retrieves sql results using php. I assign the resutls to an array by doing this $bobreport = array(); while ($row=db2_fetch_array($querystmt)) { array_push($bobreport, $row); } i can then write the rows of returned data after some column headers using this... foreach ($bobreport as $value) { echo "<tr><td>$value[0]</td><td>$value[1] ..... } The particular report I'm working on now has a redundant date and time in every row that I omit in the foreach loop because I just want to show it once above the table somewhere. This doesn't seem to work in accomplishing that... echo "This data was updated ".$bobreport[0][9]." at ".$bobreport[0][10] ; All I seem to get in the report is "This data was updated at". Please help. Similar TutorialsHi everyone! Nice to meet/see/read you. This is my first post and it will probably be a lame one so apologies. I'm a pretty good frontend designer and I've always struggled to learn PHP and my new job is forcing it on me so I'm happy in a "throw me in the deep end" kinda way. I am really stuck! I have a single page that is using jquery to scroll my content left and right via the menu (example attached). What I am trying to do is when on the homepage, don't show the "main logo". When on any other link, show it. I immediately thought of an if/else statement but realised I don't know what or how exactly to target since everything is on the same page and the URL doesn't change. Could I target the image title that is the only image on the homepage? So, something like: <?PHP $image_title = 'home'; if (XXXXX($image_title)) { echo "IMAGE"; } else { echo "NO IMAGE"; } ?> I know that's wrong, I put XXX where I feel like something possibly helpful should go. Heh. I'm not asking for someone to write code for me, I'm happy to learn but but I would be very grateful if someone could just guide me to what I need to do and off to Google I will go. I haven't been able to find anything that is like: "if image title equals". Hmm... I hope I can do this with PHP. Thanks again, Linda I am retrieving values in form of array from a database table and out of the I have to build multidimensional array depending upon the parent->child relationship in the same array. The result is as => Array ( => Array ( [label] => Shirt [uri] => # ) [1] => Array ( [label] => Jeans [uri] => # ) [2] => Array ( [label] => Lowers [uri] => # ) [3] => Array ( [label] => T-Shirts [uri] => # ) [4] => Array ( [label] => cotton shirt [uri] => # ) [5] => Array ( [label] => Trousers [uri] => # ) ) each is related to some parent-id. Can any body me any idea. Hello can anyone help me out with code to create a 2 dimension array from 2 single dimension array. for example $path = array('base', 'category', 'subcategory', 'item'); $location=array('india','USA','UK','RUSSIA',); now i need to have a @D array which have the following structure $final[0]=array('base','india'); $final[1]=array('category','USA'); $final[2]=array('subcategory','UK'); $final[3]=array('item','RUSSIA'); hey everyone will you please assist. I'm getting data from a mysql database. And I want to assign the data to a single value, if possible For example, in my database I have 2 columns, name and group Lets say John, Peter and Cathy belongs to group 555, where Sally and Marcus belongs to group 777. So my sql query outputs all users in group 555 Is there a way to assign the search result to a vlue, for example $result = ??? and If I said echo $result, it should show the users who belongs to group 555 as an example. I tried to use row[Name][1]; but it doesnt work. The thing is, I can display the data the way I am familiar with, but I'm sending an automated email to myself, containing the users. So if I would used a for each statement, the mail will trigger and send a copy for every count, in this case, 3 times. And thats my huge problem. The mail must trigger only once, containing the users in my search query, in this case, group 555. Any help will be appreciated Thank you I came up with this but it outputs the value 3 times... (because there are 3 variables) ie mathsmathsmaths How do I fix this or do it the correct way? Thanks Code: [Select] $subject = "maths"; $phone = "1235"; $colour = "red"; $all_vars = compact("subject", "phone", "colour"); get_value($subject); function get_value($variable){ global $all_vars; foreach($all_vars as $key=>$value){ if ($key = $variable) { echo $key; } } } Hi Guys, I have 6 file upload fileds in an array. When i try to return the error messages at this link: http://www.php.net/manual/en/features.file-upload.errors.php i get an error displayed for every upload box. I was wondering if it is possible to simply return 1 error instead of the 6? For example rather than getting "No File Uploaded No File Uploaded No File Uploaded No File Uploaded No File Uploaded No File Uploaded" i simply get "No File Uploaded". Also If only some files are uploaded no error should be displayed. The code i am using is: foreach ($_FILES['image']['error'] as $key => $error) { if ($error == UPLOAD_ERR_NO_FILE) { echo "No File Uploaded"; } I have tried using "break;" which works in leaving only 1 error, however the error is still displayed if less than 6 files are uploaded. All help greatly appreciated. Thanks Hi guys, I am using this oAuth library https://github.com/elbunce/oauth2-php But more specifically these lines of code: protected function getToken($token, $isRefresh = true) { try { $tableName = $isRefresh ? self::TABLE_REFRESH : self::TABLE_TOKENS; $tokenName = $isRefresh ? 'refresh_token' : 'oauth_token'; $sql = "SELECT $tokenName, client_id, expires, scope, user_id FROM $tableName WHERE token = :token"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':token', $token, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result !== FALSE ? $result : NULL; } catch (PDOException $e) { $this->handleException($e); } } However, this is retuning no value. If I modify the code to be: protected function getToken($token, $isRefresh = true) { return $token; } It returns the $token value, so the $token is definitely being passed to the function. The code should return an associative array: i.e., $token["expires"], $token["client_id"], $token["userd_id"], $token["scope"], etc Also $token should not === NULL. PS. I run a few checks on $tableName = $isRefresh ? self::TABLE_REFRESH : self::TABLE_TOKENS; $tokenName = $isRefresh ? 'refresh_token' : 'oauth_token'; And they are returning the correct values. Which from my thinking narrows it down to: $sql = "SELECT $tokenName, client_id, expires, scope, user_id FROM $tableName WHERE token = :token"; $stmt = $this->db->prepare($sql); $stmt->bindParam(':token', $token, PDO::PARAM_STR); $stmt->execute(); $result = $stmt->fetch(PDO::FETCH_ASSOC); return $result !== FALSE ? $result : NULL; Any and all help is greatly appreciated. Thanks in advance. Hi all,
I am using foreach statement to gather records and program levenshtein to detect any misspellings and suggesting the correct words.
The thing is i am unable to convert all those strings into a single array.
After trying to correct this issue so many times, i wonder if it is really possible to convert strings into a single array?
Any input is welcome
Quote from: Hollows on August 20, 2010, 11:29:25 AM I have an array that is pulling 10 results from a db like this - <?php $result = mysql_query("SELECT * FROM inbox ORDER BY id DESC LIMIT 0,10"); while ($row = mysql_fetch_array($result)) { <div class="<?php echo $row['class']; ?>"> <?php echo $row['name']; echo $row['message']; ?> </div> basically 'class' is defined in an earlyier part of the script and is used to tell the css what class to display - as I'm sure you can see. What I'd like todo then be able to update the class of a message once I have read it, so update the class table with something like 'read' so the css will then be based on .read not what ever was set by the form, either using a link or form button inside each of the 10 results from the array. I've managed to update one by using - Code: [Select] mysql_query("UPDATE shoutbox SET class = 'read' WHERE id = ''XX"); // XX should be row id But I had to set that myself and point the id to the row id I wanted to change - How can I have that already populated with the row for the id that triggered it? To be clear so it looks like - Name Message read button _____________ Name Message read button _____________ Name Message read button _____________ and so on... Would I be better going by check boxes and one submit button? If so how could I implement that? I can provide the full code I've written if it helps Thank you in advance Hi I have a results page from a MySQL query and I have implemented pagination to present data in chunks of 25 per page in a table view (each row => 1 entry). My problem is that next to each data row, I have a selection checkbox, and if the user clicks on it, he can download the selected entries. This thing worked OK before I employed paginated view, when I presented all data in one page. Now, if I select e.g. 2 entries in page 1, then I jump to page 12 and select another 2 entries, if I click on the "Retrieve" button, I get only the last 2 entries (from the last page visited). How can I solve this problem? With JS? Can I use PHP only? hi, i am pulling data from a database, a picture and some text, i am able to have the records display vertically but i want them to display across the screen rather than downwards, but because of the page size, i only want 2 results per line. does any one know how i can do this? thanks in advance. Des This is the code i am currently using $result = mysql_query("select * from staff'"); echo "<table border='0' cellpadding='10' cellspacing='0'>"; echo "<tr>"; while($row = mysql_fetch_array($result)) { echo "<td><img src=../upload/".$row['Pic']." border='0' width='140' height='105' /></td>"; echo "<td>".$row['Name']."</br><b>".$row['Role']."</b></td>"; } echo "</tr>"; echo "</table>"; Hey, I am trying to make and then read an array of items. Can someone help please? I have a database field that holds an unlimited number of codes, and I need to get those codes.... at the moment I have a section of php $products= array($products); $array = array_values($products); print_r($array); which generates Array ( => FRE0001,FRE0009,FRE0009,FRE0024,FRE0024 ) as the output... What I need is to know how many of each code there are and the different codes.... i.e. 1 x FRE0001, 2 x FRE0009, 2 x FRE0024 Whats the best way to output the array and then count? I've never used array's because I've always found a way to do something without them. I have finally taught myself how array's work, but I cannot seem to add a key and value to an array without my code creating another array inside that one. I'm not sure what I'm doing wrong, but this is what I'm getting. From what I understand, print_r is suppose to print out an array. This is what my print_r displays: Array ( [knife] => 2000 ) Array ( [baseballbat] => 2000 [knife] => 2000 ) Array ( [colt] => 2000 [knife] => 2000 [baseballbat] => 2000 ) Array ( [deserteagle] => 2000 [baseballbat] => 2000 [knife] => 2000 [colt] => 2000 ) Array ( [ingram] => 2000 [colt] => 2000 [knife] => 2000 [baseballbat] => 2000 [deserteagle] => 2000 ) Array ( [deserteagle] => 2000 [ump40] => 2000 [baseballbat] => 2000 [knife] => 2000 [colt] => 2000 [ingram] => 2000 ) Array ( [colt] => 2000 [ingram] => 2000 [deserteagle] => 2000 [knife] => 2000 [baseballbat] => 2000 [ump40] => 2000 [grenades] => 958 ) Array ( [baseballbat] => 2000 [ump40] => 2000 [colt] => 2000 [knife] => 2000 [deserteagle] => 2000 [ingram] => 2000 [grenades] => 958 ) Array ( [deserteagle] => 2000 [ingram] => 2000 [baseballbat] => 2000 [knife] => 2000 [colt] => 2000 [ump40] => 2000 [grenades] => 958 ) Array ( [colt] => 2000 [ump40] => 2000 [deserteagle] => 2000 [knife] => 2000 [baseballbat] => 2000 [ingram] => 2000 [grenades] => 958 ) Array ( [baseballbat] => 2000 [ingram] => 2000 [colt] => 2000 [knife] => 2000 [deserteagle] => 2000 [ump40] => 2000 [grenades] => 958 ) Array ( [deserteagle] => 2000 [ump40] => 2000 [baseballbat] => 2000 [knife] => 2000 [colt] => 2000 [ingram] => 2000 [grenades] => 958 ) Array ( [colt] => 2000 [ingram] => 2000 [deserteagle] => 2000 [knife] => 2000 [baseballbat] => 2000 [ump40] => 2000 [grenades] => 958 ) Array ( [baseballbat] => 2000 [ump40] => 2000 [colt] => 2000 [knife] => 2000 [deserteagle] => 2000 [ingram] => 2000 [grenades] => 958 ) Array ( [deserteagle] => 2000 [ingram] => 2000 [baseballbat] => 2000 [knife] => 2000 [colt] => 2000 [ump40] => 2000 [grenades] => 958 ) Array ( [ump40] => 2000 [pepperspray] => 2000 [colt] => 2000 [knife] => 2000 [ingram] => 2000 [baseballbat] => 2000 [deserteagle] => 2000 [grenades] => 958 ) Array ( [baseballbat] => 2000 [deserteagle] => 2000 [flashbangs] => 2000 [ump40] => 2000 [ingram] => 2000 [pepperspray] => 2000 [colt] => 2000 [knife] => 2000 [grenades] => 958 ) Array ( [pepperspray] => 2000 [colt] => 2000 [knife] => 2000 [baseballbat] => 2000 [ingram] => 2000 [ump40] => 2000 [deserteagle] => 2000 [flashbangs] => 2000 [teargas] => 1800 [grenades] => 958 ) Array ( [pepperspray] => 2000 [deserteagle] => 2000 [flashbangs] => 2000 [ingram] => 2000 [ump40] => 2000 [baseballbat] => 2000 [colt] => 2000 [knife] => 2000 [tasergun] => 1800 [teargas] => 1800 [grenades] => 958 ) Array ( [pepperspray] => 2000 [colt] => 2000 [knife] => 2000 [ump40] => 2000 [baseballbat] => 2000 [ingram] => 2000 [deserteagle] => 2000 [flashbangs] => 2000 [teargas] => 1800 [tasergun] => 1800 [combathelmet] => 1600 [grenades] => 958 ) Array ( [ingram] => 2000 [pepperspray] => 2000 [flashbangs] => 2000 [baseballbat] => 2000 [deserteagle] => 2000 [ump40] => 2000 [colt] => 2000 [knife] => 2000 [tasergun] => 1800 [teargas] => 1800 [combathelmet] => 1600 [grenades] => 958 [kevlarvest] => 271 ) Array ( [ump40] => 2000 [ingram] => 2000 [knife] => 2000 [deserteagle] => 2000 [colt] => 2000 [baseballbat] => 2000 [pepperspray] => 2000 [flashbangs] => 2000 [teargas] => 1800 [tasergun] => 1800 [combathelmet] => 1600 [grenades] => 958 [kevlarvest] => 271 ) Array ( [baseballbat] => 2000 [ump40] => 2000 [flashbangs] => 2000 [colt] => 2000 [pepperspray] => 2000 [deserteagle] => 2000 [ingram] => 2000 [knife] => 2000 [tasergun] => 1800 [teargas] => 1800 [combathelmet] => 1600 [grenades] => 958 [kevlarvest] => 271 ) Array ( [deserteagle] => 2000 [baseballbat] => 2000 [knife] => 2000 [pepperspray] => 2000 [ingram] => 2000 [colt] => 2000 [ump40] => 2000 [flashbangs] => 2000 [teargas] => 1800 [tasergun] => 1800 [combathelmet] => 1600 [grenades] => 958 [kevlarvest] => 271 ) Notice how the first array has one key/value, the second has the same value as the first plus an additional value. The third array has the same values as the second array plus an additional value. I'm confused as to whether my array is correct, and that print_t is just showing me how the array has changed everytime the while loop went through, or there is an error in my code and my array is not correct. I want to get this cleared before I continue. Here is my code so far: Code: [Select] <? $user = $_GET['user']; $attacks = $_GET['attacks']; $quser = mysql_query("SELECT * FROM user WHERE username = '$user'"); $nuser = mysql_num_rows($quser); if ($nuser == 1) { $ruser = mysql_fetch_array($quser); $totalpower = $ruser[power] + $ruser[defense]; $sabpower = round ($totalpower * $sabdmg); $ramount = mysql_fetch_array(mysql_query("SELECT * FROM user_items WHERE username = '$user'")); $wa = array(); $qweps = mysql_query("SELECT * FROM weaponstore ORDER BY type ASC, price ASC"); while ($rweps = mysql_fetch_array($qweps)) { $wepname = $rweps[colname]; $wepamount = $ramount[$wepname]; if ($wepamount >= 1) { $wa[$wepname] = $wepamount; } arsort($wa); print_r($wa); } } ?> Basically the code should add the $wepname as the key and $wepamount as the value to an array $wa only if $wepamount is >= 1, but the way my print_r is showing it I'm just confused as to why I'm getting a bunch of arrays and not just one. PHP script return 20Â UL LISTÂ values like, < ul >
A < /ul > How to display UL LIST into row wise 5 columns like
A B C D Hello everyone, I have a question with the use of the functon in_array... I have a list of categories in my table and I want to know if a specific category exists so I am doing this: $categoriasexistentes= mysql_query("SELECT * FROM LugaresTuristicos WHERE DestinoPeg='$LinkDestino' GROUP BY Clasificacion ") or die(mysql_error()); $array = mysql_fetch_array($categoriasexistentes); print_r($array); WHAT IS DISPLAYED BY print_r (there should be much more categories) IS THIS: Array ( => Bar [Clasificacion] => Bar ) If I ad this all categories are displayed: while($categoria = mysql_fetch_array($categoriasexistentes)) { $todas=$categoria['Clasificacion']; ?> <?php echo"{$todas} - "; ?> <?php }; ?> Hi guys, Need some help with arrays! The following code puts ALL dates into an array, or should I say should. Because this: do { $start = $row_getCalendarDates['page_date']; $end = $row_getCalendarDates['page_date02']; $init_date = strtotime($start); $dst_date = strtotime($end); $offset = $dst_date-$init_date; $dates = floor($offset/60/60/24) + 1; $booked=0; while ($booked < $dates) { $newDateFinal[] = date("Y-m-d", mktime(12,0,0,date("m", strtotime($start)), (date("d", strtotime($start)) + $booked), date("Y", strtotime($start)))); $booked++; } print_r($newDateFinal); } while ($row_getCalendarDates = mysql_fetch_assoc($getCalendarDates)); Infact prints something like so when i have multiple results: Array ( [0] => 2010-12-01 [1] => 2010-12-02 [2] => 2010-12-03 ) Array ( [0] => 2010-12-01 [1] => 2010-12-02 [2] => 2010-12-03 [3] => 2010-11-01 [4] => 2010-11-02 [5] => 2010-11-03 [6] => 2010-11-04 [7] => 2010-11-05 [8] => 2010-11-06 [9] => 2010-11-07 [10] => 2010-11-08 ) These are 2 results coming from the database, so what it is doing is putting both into arrays, but I 'NEED' them iin a single array, how on earth do I go about doing this? Note however, how the first array has the first set of results but the second has them all ... this is affecting my code and so, need to somehow reference and get rid of the first array. Hope someone can help! Regards, Joe. Why wont my radio array show the value that was selected. If a user select a radio then the value should be printed. But it should print the question id then the choice that was chosen for that question id. Code: [Select] <?php $gender = $_POST["choice"]; $que_ID = $_POST["Que_ID"]; foreach ($gender as $key => $value) { echo $key." - ".$value."";} ?> Code: [Select] $intNum = 1; $intnumber = 1; while( $info = mysql_fetch_array( $sqll )){ echo "<input type='hidden' name=\"Que_ID\" value=\"{$info['Que_ID']}\" /> "; echo " $intNum, {$info['Que_Question']} <br />\n"; $intNum++; for ($i =1; $i < 5; $i++) { echo "<input type=\"Radio\" name=\"choice[{$info['Que_ID']}][]\" />{$info['Que_Choice'.$i]}<br />\n"; $intnumber++; hi. Basically, I am trying to set up a random bible verse script. I found an rss/xml feed he http://www.mybiblescripture.com/rss/bible.php?fmt=daily&trans=KJV Using the following code, I am attempting to parse the feed in to an array: Code: [Select] <?php function fetchXML($url) { //initialize library $ch = curl_init(); //used to make us look like a browser $useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"; //set the url curl_setopt ($ch, CURLOPT_URL, $url); //set that I want to wait for a response curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); //make us look like a web browser curl_setopt ($ch, CURLOPT_USERAGENT, $useragent); //get data $data = curl_exec($ch); //clean up curl_close($ch); //return xml data return $data; } define("USE_CURL", true); $url = "http://www.mybiblescripture.com/rss/bible.php?fmt=daily&trans=KJV"; //get xml doc with info $data = fetchXML($url); //create a SimpleXML object to parse the xml $char_xml = new SimpleXmlElement($data); echo print_r($char_xml); ?> Which gives me the following output: Code: [Select] SimpleXMLElement Object ( [@attributes] => Array ( [version] => 2.0 ) [channel] => SimpleXMLElement Object ( [title] => My Bible Scripture - Bible Verse of the Day (KJV) [link] => http://www.mybiblescripture.com/ [description] => Verse of the Day - King James Version [language] => en-us [pubDate] => SimpleXMLElement Object ( ) [generator] => CPG-Nuke Dragonfly [copyright] => My Bible Scripture [category] => Religion [image] => SimpleXMLElement Object ( [width] => 111 [height] => 40 [url] => http://www.mybiblescripture.com/images/logo.gif [title] => My Bible Scripture [link] => http://www.mybiblescripture.com/ ) [item] => Array ( [0] => SimpleXMLElement Object ( [title] => Corinthians I 10:17 [link] => http://www.mybiblescripture.com/Bible/l_op=view-verse/lid=29613/trans=KJV.html [description] => For we being many are one bread, and one body: for we are all partakers of that one bread. (KJV) [pubDate] => SimpleXMLElement Object ( ) ) [1] => SimpleXMLElement Object ( [title] => Bible Verses [link] => http://www.mybiblescripture.com [description] => Find more Bible Scripture [pubDate] => Fri, 11 Mar 2011 00:45:06 GMT ) ) ) ) 1 What I am trying to do is pull ONLY [title] => Corinthians I 10:17 and its accompanying verse [description] => For we being many are one bread, and one body: for we are all partakers of that one bread. (KJV). I am very bad at trying to read multi-dim arrays and can't for the life of me figure out how to print the aforementioned keys. Could anyone help me here? thanks The code below is showing "undefined" and "OBJECT" errors
What am I doing wrong to build this multi-dimensional array?
And why can't I paste it to this page???????????????????????
I'm trying to get stream to show if online or offline, the check.php works just fine if i don't have "$f3" in line 5 but I need to collect from array and put into there. Usually the array works just fine but this time it's not Well anyway the error I'm getting is Code: [Select] Warning: DOMDocument::load() [domdocument.load]: Couldn't resolve host name in /home/dahdop/public_html/pvpstreams.com/table/check.php on line 5 Warning: DOMDocument::load(http://x.api.channel.livestream.com/2.0/livestatus.xml) [domdocument.load]: failed to open stream: operation failed in /home/dahdop/public_html/pvpstreams.com/table/check.php on line 5 Warning: DOMDocument::load() [domdocument.load]: I/O warning : failed to load external entity "http://x.api.channel.livestream.com/2.0/livestatus.xml" in /home/dahdop/public_html/pvpstreams.com/table/check.php on line 5 Offline | Viewers: To me its taking away an "x" and making the array blank for some reason. My site is pvpstreams.com if you want to see error in action. My table.php file Code: [Select] <script language="javascript"> imageX1='plus'; imageX2='plus'; imageX3='plus'; function toggleDisplay(e){ imgX="imagePM"+e; tableX="table"+e; imageX="imageX"+e; tableLink="tableHref"+e; imageXval=eval("imageX"+e); element = document.getElementById(tableX).style; if (element.display=='none') {element.display='block';} else {element.display='none';} if (imageXval=='plus') {document.getElementById(imgX).src='http://www.pvpstreams.com/icons/wowicon.png';eval("imageX"+e+"='minus';");document.getElementById(tableLink).title='Hide WoW';} else {document.getElementById(imgX).src='http://www.pvpstreams.com/icons/wowicon.png';eval("imageX"+e+"='plus';");document.getElementById(tableLink).title='Show WoW';} } </script> <?php $username="x"; $password="x"; $tmp="x"; mysql_connect(localhost,$username,$password); @mysql_select_db($tmp) or die( "Unable to select database"); $query="SELECT * FROM users"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table class="sortable" id="wow" border="1" cellpadding="0" cellspacing="0" style="margin-left:auto;margin-right:auto;text-align:left"> <tr> <th><font face="Arial, Helvetica, sans-serif">Character</font></th> <th><font face="Arial, Helvetica, sans-serif">Xfire</font></th> <th><font face="Arial, Helvetica, sans-serif">Livestream</font></th> <th><font face="Arial, Helvetica, sans-serif">Livestream Status</font></th> <th><font face="Arial, Helvetica, sans-serif">Team Members</font></th> <th><font face="Arial, Helvetica, sans-serif">Realm</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"wowcharacter"); $f2=mysql_result($result,$i,"username"); $f3=mysql_result($result,$i,"livestream"); $f4=mysql_result($result,$i,"wowserver"); $f5=mysql_result($result,$i,"wowplayer1"); $f6=mysql_result($result,$i,"wowplayer2"); $f9=mysql_result($result,$i,"wowplayer3"); $f7=mysql_result($result,$i,"wowrealm"); $f8=mysql_result($result,$i,"xfire"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php Echo "<a class=blue href=http://$f9.battle.net/wow/en/character/$f7/$f1/simple>$f1</a>"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php Echo "<a class=blue href=http://www.pvpstreams.com/xfire.php?user=$f2>$f8</a>"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo "<a class=blue href=http://www.pvpstreams.com/livestream.php?user=$f2>$f3</a>"; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"> <?php include("check.php"); ?> </font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo "<img src=wclassicons/$f5.png><img src=wclassicons/$f6.png><img src=wclassicons/$f9.png>" ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f7; ?></font></td> </tr> <?php $i++; } ?> </table> My check.php file Code: [Select] <?php $objDOM = new DOMDocument(); // channel name here **INSERT** $objDOM->load("http://x$f3x.api.channel.livestream.com/2.0/livestatus.xml"); //make sure path is correct $channel = $objDOM->getElementsByTagName("channel"); foreach( $channel as $value ) { $isLives = $value->getElementsByTagName("isLive"); $isLive = $isLives->item(0)->nodeValue; $viewers = $value->getElementsByTagName("currentViewerCount"); $viewer = $viewers->item(0)->nodeValue; } if($isLive == "true") { echo "<font color='#00FF00'>Online</font>"; echo " | Viewers: " . $viewer; } else { echo "<font color='#FF0000'>Offline</font>"; echo " | Viewers: " . $viewer; } ?> Any help appreciated! |