Icy Phoenix

     
 


Post new topic  Reply to topic 
Page 1 of 1
 
 
Reply with quote Download Post
Post UPDATE Database Via Checkboxes 
 
Hi Guys ,

I hope someone can help me quick.

I have a PHP Script which i made:-

Code: [Download] [Hide] [Select]
<?php
/***************************************************************************
 *                                template.php
 *                            -------------------
 *   begin                : Saturday, Okt 10, 2003
 *   copyright         : (C) 2008 Raimon Meuldijk
 *   email                : Raimon@phpBBservice.nl
 *
 *   $Id:  $
 *
 * Modified by Lopalong 3rd Aug 2008 < http://icythemes.com >.
 *
 ***************************************************************************/

/***************************************************************************
 *
 *   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 . '&amp;order=' . $sort_order, $total_species , 50, $start) . '&nbsp;';
}
$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);

   }
?>


I have the HTML page designed as such:-

Code: [Download] [Hide] [Select]
<style type="text/css">
<!--
.style4 {font-size: 18px}
.style5 {color: #660000}
.style7 {color: #003300}
.style11 {font-size: 14px}
.style12 {font-size: 16px}
.style13 {
    color: #FF0000;
    font-weight: bold;
}
.style14 {color: #003300; font-weight: bold; }
.style15 {color: #993300; }
-->
</style>
  <p class="style7"><strong>Tick Lists of :-</strong> <span class="style13">{USERNAME}</span></p>
  <p class="style13"><strong>WILL BE UP AND RUNNING SOON -- UNTIL THEN, KEEP A PAPER COPY ;-) !!!</strong></p>
  <p class="style13">&nbsp;</p>
  <table width="800" border="1" cellpadding="0" cellspacing="0" bordercolor="#99CC99">
    <tr>
      <th class="style14" scope="col">No.</th>
      <th class="style14" scope="col">Species</th>
      <th class="style14" scope="col">Scientific</th>
      <th class="style14" scope="col">Type</th>
      <th class="style14" scope="col">Picture</th>
      <th scope="col"><span class="style14">Life List</span></th>
      <th scope="col"><span class="style14">2009 List</span></th>
      <th scope="col"><span class="style14">Edit</span></th>
    </tr>
    <!-- BEGIN life -->
    <tr>
      <th class="style7" scope="col">{life.LIFE_COUNT}</th>
      <th class="style15" scope="col">{life.LIFE_SPECIES}</th>
      <th scope="col"><span class="style7">{life.LIFE_LATIN} </span></th>
      <th scope="col"><span class="style7">{life.LIFE_TYPE} </span></th>
      <th scope="col"><input name="checkbox" type="checkbox" {life.LIFE_PICTURE} /></th>
      <th scope="col"><input name="checkbox" type="checkbox" {life.LIFE_TICKED} /></th>
      <th scope="col"><input name="checkbox" type="checkbox" {life.2009_TICKED} /></th>
      <th scope="col"><span class="style7">
        <input name="button" type="submit" class="style14" id="button" value="Update" />
      </span></th>
    </tr>
    <!-- END life -->
  </table>
</form>
<form method="post" action="{S_MODE_ACTION}">
<table class="empty-table" width="100%" cellspacing="0" cellpadding="0" border="0">
  <p>
    <label></label>
  </p>
<tr>
        <td align="left"><span class="pagination">{PAGINATION}</span></td>
        <td align="right" valign="top" nowrap="nowrap">
  <form method="post" action="{S_MODE_ACTION}">
                <span class="genmed">{L_SELECT_SORT_METHOD}:&nbsp;{S_MODE_SELECT}&nbsp;&nbsp;{L_ORDER}&nbsp;{S_ORDER_SELECT}&nbsp;&nbsp;<input type="submit" name="submit" value="{L_SUBMIT}" class="liteoption jumpbox" /></span>
  </form>
        </td>
    </tr>
    <tr>
        <td align="left"><span class="gensmall">{PAGE_NUMBER}</span></td>
        <td valign="top" align="right">{JUMPBOX}</td>
    </tr>
</table>




Which can be seen here -- 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 ??
 



 
AndyGpySend private messageVisit poster's website  
Back to topPage bottom
Icy Phoenix is an open source project, you can show your appreciation and support future development by donating to the project.

Support us
 
Post new topic  Reply to topic  Page 1 of 1
 


Display posts from previous:    

HideWas this topic useful?

Link this topic
URL
BBCode
HTML




 
Permissions List
You cannot post new topics
You cannot reply to topics
You cannot edit your posts
You cannot delete your posts
You cannot vote in polls
You cannot attach files
You can download files
You cannot post calendar events