Alper Posted October 28, 2012 Share Posted October 28, 2012 With limited php/sql skills im trying to change some code so it fits my project. Of these 3 listings only the 1 with ID 6 got all fields stored with data in SQL. For ID 4 and 5 the table listing for "Third build" is empty in SQL. But when listing the data for "Third build" is kept in memory from ID 6 and repost the information for ID 4 and 5. I think the problem is within the php code generating the listing and its as this: // commons define("IN_PHPRAID", true); require_once('./common.php'); // page authentication define("PAGE_LVL","anonymous"); require_once("includes/authentication.php"); /************************************************************* * Setup Record Output Information for Data Table *************************************************************/ // Set StartRecord for Page if(!isset($_GET['Base']) || !is_numeric($_GET['Base'])) $startRecord = 1; else $startRecord = scrub_input($_GET['Base']); // Set Sort Field for Page if(!isset($_GET['Sort'])||$_GET['Sort']=='') { $sortField=""; $initSort=FALSE; } else { $sortField = scrub_input($_GET['Sort']); $initSort=TRUE; } // Set Sort Descending Mark if(!isset($_GET['SortDescending']) || !is_numeric($_GET['SortDescending'])) $sortDesc = 0; else $sortDesc = scrub_input($_GET['SortDescending']); $pageURL = 'roster.php?'; /************************************************************** * End Record Output Setup for Data Table **************************************************************/ // for now, we'll let everyone view the character list $sql = "SELECT * FROM " . $phpraid_config['db_prefix'] . "chars"; $result = $db_raid->sql_query($sql) or print_error($sql, $db_raid->sql_error(), 1); $chars = array(); // get all the chars and throw them in that nice array for // output by the report class while($data = $db_raid->sql_fetchrow($result, true)) { $sql = sprintf("SELECT * FROM " . $phpraid_config['db_prefix'] . "profile WHERE profile_id=%s", quote_smart($data['profile_id'])); $data_result = $db_raid->sql_query($sql) or print_error($sql, $db_raid->sql_error(), 1); $data_profdetail = $db_raid->sql_fetchrow($data_result); $data['name'] = utf8_check($data['name']); // if ($phpraid_config['enable_armory']) // $charname = get_armorychar($data['name'], $data['guild']); // else $charname = $data['name']; // Get the Internationalized data to display from the database values: foreach ($wrm_global_races as $global_race) if ($data['race'] == $global_race['race_id']) $race = $phprlang[$global_race['lang_index']]; foreach ($wrm_global_classes as $global_class) if ($data['class'] == $global_class['class_id']) $class = $phprlang[$global_class['lang_index']]; foreach($wrm_global_specs as $global_spec) { if($data['pri_spec'] == $global_spec['spec']) $pri_spec = $phprlang[$global_spec['lang_index']]; if($data['sec_spec'] == $global_spec['spec']) $sec_spec = $phprlang[$global_spec['lang_index']]; if($data['thi_spec'] == $global_spec['spec']) $thi_spec = $phprlang[$global_spec['lang_index']]; } // Get the Guild Name to Display instead of Just the ID $sql = sprintf("SELECT guild_name FROM " . $phpraid_config['db_prefix'] . "guilds WHERE guild_id=%s",quote_smart($data['guild'])); $guild_result = $db_raid->sql_query($sql) or print_error($sql, $db_raid->sql_error(), 1); $guild_data = $db_raid->sql_fetchrow($guild_result, true); $guild_name = $guild_data['guild_name']; array_push($chars, array( 'ID'=>$data['char_id'], 'Name'=> $charname, 'Guild'=>$guild_name, 'Level'=>$data['lvl'], 'Race'=>$race, 'Class'=>$class, 'Pri_Spec'=>$pri_spec, 'Sec_Spec'=>$sec_spec, 'Thi_Spec'=>$thi_spec, 'Arcane'=>$data['arcane'], 'Fire'=>$data['fire'], 'Frost'=>$data['frost'], 'Nature'=>$data['nature'], 'Shadow'=>$data['shadow'], 'Profile'=>'<a href="admin/admin_usermgt.php?mode=details&user_id=' . $data['profile_id'] . '">' . $data_profdetail['username'] . '</a>' ) ); } if(scrub_input($_SESSION['priv_configuration'] != 1)) { hideCol('Profile'); } /************************************************************** * Code to setup for a Dynamic Table Create: roster1 View. **************************************************************/ $viewName = 'roster1'; //Setup Columns $roster_headers = array(); $record_count_array = array(); $roster_headers = getVisibleColumns($viewName); //Get Record Counts $roster_record_count_array = getRecordCounts($chars, $raid_headers, $startRecord); //Get the Jump Menu and pass it down $rosterJumpMenu = getPageNavigation($chars, $startRecord, $pageURL, $sortField, $sortDesc); //Setup Default Data Sort from Headers Table if (!$initSort) foreach ($roster_headers as $column_rec) if ($column_rec['default_sort']) $sortField = $column_rec['column_name']; //Setup Data $chars = paginateSortAndFormat($chars, $sortField, $sortDesc, $startRecord, $viewName); /**************************************************************** * Data Assign for Template. ****************************************************************/ $wrmsmarty->assign('roster_data', $chars); $wrmsmarty->assign('roster_jump_menu', $rosterJumpMenu); $wrmsmarty->assign('column_name', $roster_headers); $wrmsmarty->assign('roster_record_counts', $roster_record_count_array); $wrmsmarty->assign('header_data', array( 'template_name'=>$phpraid_config['template'], 'roster_header' => $phprlang['roster_header'], 'sort_url_base' => $pageURL, 'sort_descending' => $sortDesc, 'sort_text' => $phprlang['sort_text'], ) ); // // Start output of page // require_once('includes/page_header.php'); $wrmsmarty->display('roster.html'); require_once('includes/page_footer.php'); ?> Link to comment https://forums.phpfreaks.com/topic/269995-resetting-variable-before-each-listing-from-sql/ Share on other sites More sharing options...
Alper Posted October 28, 2012 Author Share Posted October 28, 2012 Found the error within the sql input Link to comment https://forums.phpfreaks.com/topic/269995-resetting-variable-before-each-listing-from-sql/#findComment-1388302 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.