Jump to content

Resetting Variable Before Each Listing From Sql


Alper

Recommended Posts

With limited php/sql skills im trying to change some code so it fits my project.

 

post-133072-0-26015700-1351436009_thumb.png

 

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');

 

?>

Edited by Alper
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.