Jump to content

Deathwillow

Members
  • Posts

    30
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Deathwillow's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. // Build Query array. if ($name == '' && $level == '' && $race == '' && $gender == '' && $type == '' && $rank == '') { $query = "SELECT * FROM wow_character"; $counter = 0; } else { $counter = 0; if ($name != '') { $dataName[$counter] = "name"; $dataQuery[$counter] = $name; $counter++; } if ($level != '') { $dataName[$counter] = "level"; $dataQuery[$counter] = $level; $counter++; } if ($race != '') { $dataName[$counter] = "raceid"; $dataQuery[$counter] = $race; $counter++; } if ($gender != '') { $gender = $gender - 1; $dataName[$counter] = 'genderid'; $dataQuery[$counter] = $gender; $counter++; } if ($type != '') { $dataName[$counter] = 'classid'; $dataQuery[$counter] = $type; $counter++; } if ($rank != '') { $rank = $rank - 1; $dataName[$counter] = 'rank'; $dataQuery[$counter] = $rank; $counter++; } $x = 0; while ($x < $counter) { if ($x == 0) { $query = "SELECT * FROM wow_character WHERE $dataName[$x] = $dataQuery[$x]"; $x++; } else { $query .= " AND $dataName[$x] = $dataQuery[$x]"; $x++; } } } This is how I did it, is there a more efficient way of doing it?
  2. Alright, I may not have done it efficiently but I created a loop that builds an array and then at the end combines it into a query and it all seems to be working. Thanks for your help!
  3. Ok this is weird.... something so simple has become a fairly large and annoying issue. So I started getting the error: Warning: mysql_close(): supplied argument is not a valid MySQL-Link resource in /hermes/web03/b36/pow/IM/roster2/test.php on line 6 I made a simple test page to see if it was anything in the scripts but nothing. the page I load is: <?php $connection = mysql_connect("","","") or die(mysql_error()); $connection = mysql_select_db("") or die(mysql_error()); echo $connection; mysql_close($connection); ?> The first echo returns 1 while the next line is the one above... how is something so easy and simple going so wrong?
  4. May have babbled a little bit but I couldn't put into words what I was trying to do Just trying to give you guys a precise picture of the issue.
  5. I'm going to have trouble explaining the problem here but bare with me! So I'm trying to build a search query that search the database for information the user has entered. Basically the setup is: Editbox Editbox Dropdown Dropdown Dropdown Dropdown So the first thing I did was check to see if all those were blank to set the string as : $query = "SELECT * FROM wow_character"; if even one of those form elements aren't blank, set $query as: $query = "SELECT * FROM wow_character WHERE "; Now the problem I'm having and can't figure out is how I would code it to where if say the first editbox is empty but the second isn't it'll return the right information. The only way I can think of is using a TON of if else statements and that just doesn't seem efficient and I think there's a better cleaner and shorter way of doing it. Here's what I've done so far: // Build Query if ($name == '' && $level == '' && $race == '' && $gender == '' && $type == '' && $rank == '') { $query = "SELECT * FROM wow_character"; } else { $query = "SELECT * FROM wow_character WHERE "; } if ($name != '') { $query .= " name = '$name'"; } if ($level != '') { $query .= " AND level = '$level'"; } Now that's just testing the first 2 edit boxes, but the errors arise when: 1) if name isn't empty but level is, works like a charm 2) if name isn't empty and level isn't empty, works like a charm 3) if name is empty and level is empty, works like a charm 4) if name is empty and level isn't empty, ERROR Is there a shorter, better, more efficient way of coding this without doing: // Build Query if ($name == '' && $level == '' && $race == '' && $gender == '' && $type == '' && $rank == '') { $query = "SELECT * FROM wow_character"; } else { $query = "SELECT * FROM wow_character WHERE "; } if ($name != '') { $query .= " name = '$name'"; } if ($level != '') { if ($name == '') { $query .= " level = '$level'"; } else { $query .= " AND name = '$name'"; } } You can see where it's lengthy with just 2 with 6 it'll be a ton of if else statements... a ton... What's a better way of coding this?
  6. Actually I just went ahead and tried the above and it all seems to work like a charm now, for reference here's the final code. <?php include('news.php'); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII" /> <title>Insinuo Matris</title> <link href="main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jQuery/jquery.1.4.3.js"></script> <script type="text/javascript" src="http://static.wowhead.com/widgets/power.js"></script> </head> <body> <div id="page"> <div id="topImage"> </p> </P> </div> <div id="navBar"> <div class="navBar"> <ul> <li class="active"><a href="#">Home</a></li> <li><a href="/forums">Forums</a></li> <li><a href="/roster">Roster</a></li> <li><a href="/media">Videos</a></li> <li><a href="/loot">Loot</a></li> <li><a href="/downloads">Downloads</a></li> </ul> </div> </div> <div id="content"> <div id="contentArea"> <div id="breadCrumb"></div> <div id="contentLeft"> <?php foreach($news as $n) { echo "<div class=\"newsPost\"> <h1><span class=\"topic\"><a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$n['topic_id']}\">{$n['topic_title']}</a></span></h1> <p>{$n['post_text']}</p> <div class=\"newsPost_footer\"> <span class=\"newsPost_comments\">Comments: <a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$n['topic_id']}\">{$n['topic_replies']}</a></span><span class=\"newsPost_author\">Posted by <i><font color=\"#CCCCCC\">{$n['username']} </font>on " . $user->format_date($n['topic_time']) . "</i></span> </div> </div>"; } ?> </div> <div id="contentRight"> <div class="contentRightSetup"> <h1><span class="topic">Currently Recruiting:</span></h1> <ul class="recruitmentList"> <?php include('recruitment.php'); ?> </ul> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Loot:</span></h1> <p>Loot to be added later.</p> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Blue Posts:</span></h1> <ul> <span class="blueFeed"> <?php include('bluePosts.php'); ?> </span> </ul> </div> </div> </div> </div> </div> </body> </html> thanks to everyone who replied and help me with this issue, it's been plaguing me for a while.
  7. So should I place: <?php include('news.php'); ?> at the VERY beginning of index.php and use the array function where I need to display the information. Example of what I mean would be: <?php include('news.php'); ?> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII" /> <title>Insinuo Matris</title> <link href="main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jQuery/jquery.1.4.3.js"></script> <script type="text/javascript" src="http://static.wowhead.com/widgets/power.js"></script> </head> <body> <div id="page"> <div id="topImage"> </p> </P> </div> <div id="navBar"> <div class="navBar"> <ul> <li class="active"><a href="#">Home</a></li> <li><a href="/forums">Forums</a></li> <li><a href="/roster">Roster</a></li> <li><a href="/media">Videos</a></li> <li><a href="/loot">Loot</a></li> <li><a href="/downloads">Downloads</a></li> </ul> </div> </div> <div id="content"> <div id="contentArea"> <div id="breadCrumb"></div> <div id="contentLeft"> ** PHP LOOP HERE RECALLING THE ARRAY FROM NEWS.PHP ** </div> <div id="contentRight"> <div class="contentRightSetup"> <h1><span class="topic">Currently Recruiting:</span></h1> <ul class="recruitmentList"> <?php include('recruitment.php'); ?> </ul> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Loot:</span></h1> <p>Loot to be added later.</p> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Blue Posts:</span></h1> <ul> <span class="blueFeed"> <?php include('bluePosts.php'); ?> </span> </ul> </div> </div> </div> </div> </div> </body> </html> If i'm understanding you guys right, that should correct it right?
  8. I'm not exactly sure where in the index file this could be happening, here's what it is: <!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=US-ASCII" /> <title>Insinuo Matris</title> <link href="main.css" rel="stylesheet" type="text/css" /> <script type="text/javascript" src="jQuery/jquery.1.4.3.js"></script> <script type="text/javascript" src="http://static.wowhead.com/widgets/power.js"></script> </head> <body> <div id="page"> <div id="topImage"> </p> </P> </div> <div id="navBar"> <div class="navBar"> <ul> <li class="active"><a href="#">Home</a></li> <li><a href="/forums">Forums</a></li> <li><a href="/roster">Roster</a></li> <li><a href="/media">Videos</a></li> <li><a href="/loot">Loot</a></li> <li><a href="/downloads">Downloads</a></li> </ul> </div> </div> <div id="content"> <div id="contentArea"> <div id="breadCrumb"></div> <div id="contentLeft"> <?php include('news.php'); ?> </div> <div id="contentRight"> <div class="contentRightSetup"> <h1><span class="topic">Currently Recruiting:</span></h1> <ul class="recruitmentList"> <?php include('recruitment.php'); ?> </ul> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Loot:</span></h1> <p>Loot to be added later.</p> </div> <div class="spacer"></div> <div class="contentRightSetup"> <h1><span class="topic">Recent Blue Posts:</span></h1> <ul> <span class="blueFeed"> <?php include('bluePosts.php'); ?> </span> </ul> </div> </div> </div> </div> </div> </body> </html>
  9. So I've got a simple news script that pulls the last 5 posts in a specific phpbb3 forum but I'm getting errors on the front page whenever they don't at least open the forums before. There errors: To narrow it down a little more for everyone, When they visit the home page( http://im.deathwillow.com ) before visiting the forums they receive the following errors. Once they have at least visited, not requiring a log in, the forums ( http://im.deathwillow.com/forums ) the errors disappear. Any ideas? [phpBB Debug] PHP Notice: in file /includes/session.php on line 1024: Cannot modify header information - headers already sent by (output started at /hermes/web03/b36/pow.deathwillow21/IM/index.php: [phpBB Debug] PHP Notice: in file /includes/session.php on line 1024: Cannot modify header information - headers already sent by (output started at /hermes/web03/b36/pow.deathwillow21/IM/index.php: [phpBB Debug] PHP Notice: in file /includes/session.php on line 1024: Cannot modify header information - headers already sent by (output started at /hermes/web03/b36/pow.deathwillow21/IM/index.php: The script: <?php define('FORUM_ID', 6); // Forum ID to get data from define('POST_LIMIT', 5); // How many to get define('PHPBB_ROOT_PATH', './forums/'); // Path to phpBB (including trailing /) define('PRINT_TO_SCREEN', true); // If set to true, it will print the posts out // If set to false it will create an array $news[] with all the following info // // 'topic_id' eg. 119 // // 'topic_time' eg. 06 June, 07 (uses board default) // 'topic_replies' eg. 26 // // 'username' eg. chAos // 'topic_title' eg. "News Post" // // 'post_text' eg. just the text (formatted w/ smilies, bbcode, etc) define('IN_PHPBB', true); $phpbb_root_path = PHPBB_ROOT_PATH; $phpEx = substr(strrchr(__FILE__, '.'), 1); include($phpbb_root_path . 'common.' . $phpEx); include($phpbb_root_path . 'includes/functions_display.' . $phpEx); include($phpbb_root_path . 'includes/bbcode.' . $phpEx); // Start session management $user->session_begin(false); $auth->acl($user->data); // Grab user preferences $user->setup(); $query = "SELECT u.user_id, u.username, t.topic_title, t.topic_poster, t.forum_id, t.topic_id, t.topic_time, t.topic_replies, t.topic_first_post_id, p.poster_id, p.topic_id, p.post_id, p.post_text, p.bbcode_bitfield, p.bbcode_uid FROM ".USERS_TABLE." u, ".TOPICS_TABLE." t, ".POSTS_TABLE." p WHERE u.user_id = t.topic_poster AND u.user_id = p.poster_id AND t.topic_id = p.topic_id AND p.post_id = t.topic_first_post_id AND t.forum_id = ".FORUM_ID." ORDER BY t.topic_time DESC"; $result = $db->sql_query_limit($query, POST_LIMIT); $posts = array(); $news = array(); $bbcode_bitfield = ''; $message = ''; $poster_id = 0; while ($r = $db->sql_fetchrow($result)) { $posts[] = array( 'topic_id' => $r['topic_id'], 'topic_time' => $r['topic_time'], 'username' => $r['username'], 'topic_title' => $r['topic_title'], 'post_text' => $r['post_text'], 'bbcode_uid' => $r['bbcode_uid'], 'bbcode_bitfield' => $r['bbcode_bitfield'], 'topic_replies' => $r['topic_replies'], ); $bbcode_bitfield = $bbcode_bitfield | base64_decode($r['bbcode_bitfield']); } // Instantiate BBCode if ($bbcode_bitfield !== '') { $bbcode = new bbcode(base64_encode($bbcode_bitfield)); } // Output the posts foreach($posts as $m) { $poster_id = $m['user_id']; $message = $m['post_text']; if($m['bbcode_bitfield']) { $bbcode->bbcode_second_pass($message, $m['bbcode_uid'], $m['bbcode_bitfield']); } $message = str_replace("\n", '<br />', $message); $message = smiley_text($message); $comment = ($m['topic_replies']==1) ? 'comment' : 'comments'; if( PRINT_TO_SCREEN ) { /* Output is in the following format * * <h3>Thread Title</h3> ^ <h4 class="postinfo">date // 5 comments // poster</h4> * <p>First post test</p> * */ echo "<div class=\"newsPost\"> <h1><span class=\"topic\"><a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$m['topic_id']}\">{$m['topic_title']}</a></span></h1> <p>{$message}</p> <div class=\"newsPost_footer\"> <span class=\"newsPost_comments\">Comments: <a href=\"".PHPBB_ROOT_PATH."viewtopic.php?f=".FORUM_ID."&t={$m['topic_id']}\">{$m['topic_replies']}</a></span><span class=\"newsPost_author\">Posted by <i><font color=\"#CCCCCC\">{$m['username']} </font>on " . $user->format_date($m['topic_time']) . "</i></span> </div> </div>"; } else { $news[] = array( 'topic_id' => $m['topic_id'], // eg: 119 'topic_time' => $user->format_date($m['topic_time']), // eg: 06 June, 07 (uses board default) 'topic_replies' => $m['topic_replies'], // eg: 26 'username' => $m['username'], // eg: chAos 'topic_title' => $m['topic_title'], // eg: "News Post" 'post_text' => $message, // just the text ); } unset($message,$poster_id); } ?>
  10. Is there a way to get a array variable that increases during each loop? example: $spec[1] = array(); $spec[2] = array(); where 1 & 2 is a variable that increases?
  11. Well, they are the only 2 that aren't added to the database randomly. As far as debugging I'm not doing really anything simply because it's only happening in those 2 areas and always at the same time. For instance: -it'll get 5 people corrently -skip 1 persons professions and talents only -get another 15 right -skip 4 people's professions and talents only etc etc So the problem has to lie within that area of the code... the only thing that comes to mind is use a different counter for each loop... although honestly that shouldn't be a serious issue. It's really odd.
  12. So a brief description on what this script does so everyone knows what I'm attempting followed by the problem I am currently having. What it does: Basically what this script does is pull my guilds information from a website, www.wowarmory.com, and then pulls each characters specific information and places it all in arrays of different sorts. Once all the arrays are complete it then places it into my database for later use by myself. I currently have it updating once a day as you can only pull so much information from the website before it puts a 12 hour block on you. <?php /////////////////////////////////////////////// // Gets guild list from www.wowarmory.com // ///////////////////////////////////////////// $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://www.wowarmory.com/guild-info.xml?r=Gorgonnash&n=Midnight%20Reveries&p=1"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"); $armory = curl_exec($ch); curl_close($ch); print_r($armory); /////////////////////////////// // Open 2 new DOMDocuments // ///////////////////////////// $doc = new DOMDocument(); $doc->loadXML($armory); $doc2 = new DOMDocument(); /////////////////////////////// // Connects to database // ///////////////////////////// $connection = mysql_connect("server", "username", "password") or die(mysql_error()); $connection = mysql_select_db("database name") or die(mysql_error()); /////////////////////////////////////// // truncate the wow_character table // ///////////////////////////////////// $refresh = ("TRUNCATE TABLE wow_character"); mysql_query($refresh); /////////////////////////////////////////////////////////////////////////////////// // Checks database for character, if exists updates them, if not adds them. // ///////////////////////////////////////////////////////////////////////////////// $memberList = $doc->getElementsByTagName("character"); foreach($memberList as $toon) { $data = array( 'NAME' => $toon->getAttribute("name"), 'RACEID' => $toon->getAttribute("raceId"), 'LEVEL' => $toon->getAttribute("level"), 'CLASSID' => $toon->getAttribute("classId"), 'GENDERID' => $toon->getAttribute("genderId"), 'RANK' => $toon->getAttribute("rank"), 'ACHPOINT' => $toon->getAttribute("achPoints"), ); $temp = "http://www.wowarmory.com/character-sheet.xml?r=Gorgonnash&n=" . $data['NAME']; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $temp); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1"); $uArmory = curl_exec($ch); curl_close($ch); $doc2->loadXML($uArmory); $x = 1; $userArmory = $doc2->getElementsByTagName("talentSpec"); foreach ($userArmory as $toon2) { if ($x == 1) { $spec1 = array( 'TREE1' => $toon2->getAttribute('treeOne'), 'TREE2' => $toon2->getAttribute('treeTwo'), 'TREE3' => $toon2->getAttribute('treeThree'), 'ICON' => $toon2->getAttribute('icon'), 'PRIM' => $toon2->getAttribute('prim'), 'ACTIVE' => '', ); if ($toon2->getAttribute('active') == 1) { $spec1['ACTIVE'] = 1; } } elseif ($x == 2) { $spec2 = array( 'TREE1' => $toon2->getAttribute('treeOne'), 'TREE2' => $toon2->getAttribute('treeTwo'), 'TREE3' => $toon2->getAttribute('treeThree'), 'ICON' => $toon2->getAttribute('icon'), 'PRIM' => $toon2->getAttribute('prim'), 'ACTIVE' => '', ); if ($toon2->getAttribute('active') == 1) { $spec2['ACTIVE'] = 1; } } else { echo "To many talent trees"; } $x++; } $x = 1; $userArmory = $doc2->getElementsByTagName("skill"); foreach ($userArmory as $toon2) { if ($x == 1) { $prof1 = array( 'PROF' => $toon2->getAttribute("name"), 'LEVEL' => $toon2->getAttribute("value"), 'MAX' => $toon2->getAttribute("max"), ); } elseif ($x == 2) { $prof2 = array( 'PROF' => $toon2->getAttribute("name"), 'LEVEL' => $toon2->getAttribute("value"), 'MAX' => $toon2->getAttribute("max"), ); } else { echo "To many professions?"; } $x++; } $userArmory = $doc2->getElementsByTagName("lifetimehonorablekills"); foreach ($userArmory as $toon2) { $hkills = $toon2->getAttribute("value"); } $sql_check = "SELECT * FROM wow_character WHERE NAME = '" . $data['NAME'] . "' LIMIT 1"; $res_check = mysql_query($sql_check); //if (mysql_num_rows($res_check) == 1) //{ // $row = mysql_fetch_array($res_check); // $sql_update = "UPDATE wow_character SET LEVEL='" . $data['LEVEL'] . "', GENDERID='" . $data['GENDERID'] . "', ACHPOINTS='" . $data['ACHPOINT'] . "', RANK='" . $data['RANK'] . "', HKILLS='" . $hkills . "', PROF_1='" . $prof1['PROF'] . "', PROF_1_VALUE='" . $prof1['LEVEL'] . "', PROF_1_MAX='" . $prof1['MAX'] . "', PROF_2='" . $prof2['PROF'] . "', PROF_2_VALUE='" . $prof2['LEVEL'] . "', PROF_2_MAX='" . $prof2['MAX'] . "', TALENT1TREE_1='" . $spec1['TREE1'] . "', TALENT1TREE_2='" . $spec1['TREE2'] . "', TALENT1TREE_3='" . $spec1['TREE3'] . "', TALENT1TREE_A='" . $spec1['ACTIVE'] . "', TALENT1PRIM='" . $spec1['PRIM'] . "', TALENT1ICON='" . $spec1['ICON'] . "', TALENT2TREE_1='" . $spec2['TREE1'] . "', TALENT2TREE_2='" . $spec2['TREE2'] . "', TALENT2TREE_3='" . $spec2['TREE3'] . "', TALENT2TREE_A='" . $spec2['ACTIVE'] . "', TALENT2PRIM='" . $spec2['PRIM'] . "', TALENT2ICON='" . $spec2['ICON'] . "' WHERE ID='" . $row['ID'] . "' LIMIT 1 "; // $sql = mysql_query($sql_update); //} else { $sql_insert = "INSERT INTO wow_character (NAME, LEVEL, CLASSID, ACHPOINTS, GENDERID, RACEID, RANK, HKILLS, PROF_1, PROF_1_VALUE, PROF_1_MAX, PROF_2, PROF_2_VALUE, PROF_2_MAX, TALENT1TREE_1, TALENT1TREE_2, TALENT1TREE_3, TALENT1TREE_A, TALENT1PRIM, TALENT1ICON, TALENT2TREE_1, TALENT2TREE_2, TALENT2TREE_3, TALENT2TREE_A, TALENT2PRIM, TALENT2ICON) VALUES ( '" . $data['NAME'] . "', '" . $data['LEVEL'] . "', '" . $data['CLASSID'] . "', '" . $data['ACHPOINT'] . "', '" . $data['GENDERID'] . "', '" . $data['RACEID'] . "', '" . $data['RANK'] . "', '" . $hkills . "', '" . $prof1['PROF'] . "', '" . $prof1['LEVEL'] . "', '" . $prof1['MAX'] . "', '" . $prof2['PROF'] . "', '" . $prof2['LEVEL'] . "', '" . $prof2['MAX'] . "', '" . $spec1['TREE1'] . "', '" . $spec1['TREE2'] . "', '" . $spec1['TREE3'] . "', '" . $spec1['ACTIVE'] . "', '" . $spec1['PRIM'] . "', '" . $spec1['ICON'] . "', '" . $spec2['TREE1'] . "', '" . $spec2['TREE2'] . "', '" . $spec2['TREE3'] . "', '" . $spec2['ACTIVE'] . "', '" . $spec2['PRIM'] . "', '" . $spec2['ICON'] . "' )"; $sql = mysql_query($sql_insert); sleep(3); $spec1 = array(); $spec2 = array(); $data = array(); $prof1 = array(); $prof2 = array(); } /////////////////////////// // Close connection. // ///////////////////////// echo "Database updated."; mysql_close($connection); ?> What the problem is: Quite simply it seems to be dropping random numbers of characters specs and professions. Their isn't a rhyme or reason as to why from what I can tell. My closest guess would be it might be clearing the array before it enter the database? but the counter to that is why is it only doing it for the specs and not the other information such as name/race/class etc. My guess as to where my problem might be is somewhere in this section of the code: $x = 1; $userArmory = $doc2->getElementsByTagName("talentSpec"); foreach ($userArmory as $toon2) { if ($x == 1) { $spec1 = array( 'TREE1' => $toon2->getAttribute('treeOne'), 'TREE2' => $toon2->getAttribute('treeTwo'), 'TREE3' => $toon2->getAttribute('treeThree'), 'ICON' => $toon2->getAttribute('icon'), 'PRIM' => $toon2->getAttribute('prim'), 'ACTIVE' => '', ); if ($toon2->getAttribute('active') == 1) { $spec1['ACTIVE'] = 1; } } elseif ($x == 2) { $spec2 = array( 'TREE1' => $toon2->getAttribute('treeOne'), 'TREE2' => $toon2->getAttribute('treeTwo'), 'TREE3' => $toon2->getAttribute('treeThree'), 'ICON' => $toon2->getAttribute('icon'), 'PRIM' => $toon2->getAttribute('prim'), 'ACTIVE' => '', ); if ($toon2->getAttribute('active') == 1) { $spec2['ACTIVE'] = 1; } } else { echo "To many talent trees"; } $x++; } $x = 1; $userArmory = $doc2->getElementsByTagName("skill"); foreach ($userArmory as $toon2) { if ($x == 1) { $prof1 = array( 'PROF' => $toon2->getAttribute("name"), 'LEVEL' => $toon2->getAttribute("value"), 'MAX' => $toon2->getAttribute("max"), ); } elseif ($x == 2) { $prof2 = array( 'PROF' => $toon2->getAttribute("name"), 'LEVEL' => $toon2->getAttribute("value"), 'MAX' => $toon2->getAttribute("max"), ); } else { echo "To many professions?"; } $x++; } If you need more information on what I'm attempting to do or why I wrote the code this way please ask, I tried to explain the problem as best I could, but if I wasn't clear enough please ask and I'll attempt to explain it a little better.
  13. Looked it up in the manual and that's pretty much exactly what I wanted to do, Thanks for the help
  14. Alright, So I'm still pretty new to this and I can't seem to figure out how to sort a query, but at the same time still get the list of things I need without using the ID... Having attempted to type this out now, I realize it's pretty hard to explain, here's the code: $result = mysql_query("SELECT * FROM `wow_character` ORDER BY `RANK` ASC"); $totalMembers = mysql_num_rows($result); $x = 1; while ($x < $totalMembers) { echo $x . " - "; $sql = "SELECT * FROM wow_character WHERE ID='" . $x . "'"; $sql = mysql_query($sql); $row = mysql_fetch_array($sql); echo $row['RANK'] . "<br>"; $x++; } mysql_close($connection); I think most of you can see where I go wrong, I get the information sorted, then I unsort it while I'm getting the information from each row... but I really don't know of another way of getting the information from the table in the order I want, hopefully you guys will know what I mean. (PS: the 2 echos were just for me to see what the order I was getting them as) ALSO note that more than one people have the same rank.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.