https://www.icyphoenix.com/viewtopic.php?f=35&t=5248&p=35271#p35271 ----------------------------------- AndyGpy Thu 01 Jan, 2009 19:51 UPDATE Database Via Checkboxes ----------------------------------- Hi Guys , I hope someone can help me quick. I have a PHP Script which i made:- [code linenumbers=false]. * ***************************************************************************/ /*************************************************************************** * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * ***************************************************************************/ define('IN_PHPBB', true); $phpbb_root_path = './'; include($phpbb_root_path . 'extension.inc'); include($phpbb_root_path . 'common.'.$phpEx); include($phpbb_root_path . '/ticklists/ticklistconfig.'.$phpEx); // standard session management $userdata = session_pagestart($user_ip); if ((!$userdata['session_logged_in']) ) { redirect(append_sid(LOGIN_MG . '?redirect=tickindex.' . $phpEx )); } else { init_userprefs($userdata); // set page title $page_title = "Scotbird Ticklists - Members only area !! "; // standard page header include($phpbb_root_path . 'includes/page_header.'.$phpEx); // Connect to the database $start = ( isset($_GET['start']) ) ? intval($_GET['start']) : 0; $start = ($start < 0) ? 0 : $start; $db = new sql_db($ticklist_mysql_host,$ticklist_mysql_username,$ticklist_mysql_password,$ticklist_mysql_db,false); if(!$db) { die("Database Connection Failed:- Please Contact Site Admin" . mysql_error()); } //Check if user has a ticklist $result = mysql_query("SHOW TABLES LIKE '".$userdata[username] ."_Life'"); if( !mysql_num_rows($result) ) { // if not then create them include_once($phpbb_root_path . '/ticklists/copylist.'.$phpEx); } // assign template $template->set_filenames(array('body' => 'tickindex.tpl')); $order_by = "referrer_hits $sort_order LIMIT $start, " . $board_config['topics_per_page']; $tbl = $userdata[username]."_Life"; $sql = "SELECT * FROM " . $tbl." LIMIT $start,50"; $result = $db->sql_query($sql); if (!($result = $db->sql_query($sql))) { die("Database Query Failed" . mysql_error()); } // This is where you would add a new VARS Array if you intend to use your own custom VARS. $i = 0; while ( $row = $db->sql_fetchrow($result) ) { $template->assign_block_vars('life', array( 'POS' => $i + 1, 'LIFE_SPECIES' => $row['species'], 'LIFE_LATIN' => $row['Latin_ID'], 'LIFE_TYPE' => $row['type'], 'LIFE_COUNT' => $start + $i, 'LIFE_DATE' => $row['Date_Seen'], 'LIFE_LOCATION' => $row['location'], 'LIFE_PICTURE' =>($row['Picture']) ? 'checked="checked"' : '', 'LIFE_TICKED' => ($row['ticked']) ? 'checked="checked"' : '', '2009_TICKED' => ($row['ticked']) ? 'checked="checked"' : '', ) ); $i++; } $template->assign_vars(array( 'USERNAME' => $userdata[username], ) ); // An attempt at pagenating the results $sql = "SELECT count(*) AS total FROM " . $tbl; if ( !($result = $db->sql_query($sql)) ) { message_die(GENERAL_ERROR, 'Error geting total list', '', __LINE__, __FILE__, $sql); } if ( $total = $db->sql_fetchrow($result) ) { $total_species = $total['total']; $pagination = generate_pagination('tickindex.' . $phpEx . '?mode=' . $mode . '&order=' . $sort_order, $total_species , 50, $start) . ' '; } $db->sql_freeresult($result); $template->assign_vars(array( 'PAGINATION' => $pagination, 'PAGE_NUMBER' => sprintf($lang['Page_of'], ( floor( $start / 50 ) + 1 ), ceil( $total_species / 50 )), 'L_GOTO_PAGE' => $lang['Goto_page'] ) ); // Build the page $template->pparse('body'); // standard page footer include($phpbb_root_path . 'includes/page_tail.'.$phpEx); } ?>[/code] I have the HTML page designed as such:- [code linenumbers=false]

Tick Lists of :- {USERNAME}

WILL BE UP AND RUNNING SOON -- UNTIL THEN, KEEP A PAPER COPY ;-) !!!

 

No. Species Scientific Type Picture Life List 2009 List Edit
{life.LIFE_COUNT} {life.LIFE_SPECIES} {life.LIFE_LATIN} {life.LIFE_TYPE}

{PAGINATION} {L_SELECT_SORT_METHOD}: {S_MODE_SELECT}  {L_ORDER} {S_ORDER_SELECT}  
{PAGE_NUMBER} {JUMPBOX}
[/code] Which can be seen here -- [url=http://www.scotbird.co.uk/ScotBird_Forum_V1/tickindex.php]Click here - USERNAME - test, PASSWORD - test My question to you guys is how can i by clicking a checkbox anywhere in the list, update that list entry, ie in the database field for the checkbox change it from a 0 to 1, and refresh the page when done. Or can someone suggest another way. This is my first PHP / TEMPLATE project and i am new to PHP but learning fast. CAN SOMEONE HELP ??