Location: PHPKode > projects > FPCode > fpcode091/fpcode/includes/edit_news_links.inc.php
<?
//
//	FPCode v0.9, Date 2002-01-11
//
//	Copyright (c) 2002 Wen-Yu Chang and FrostyPlace.com. All rights reserved.
//
//	The contents of this file constitute Original Code as defined in and
//	are subject to the GNU Library General Public License (the
//	"License").  You may not use this file except in compliance with the
//	License.  Please obtain a copy of the License at
//	http://www.gnu.org/licenses/gpl.html and read it before using this file.
//	
//	This Original Code and all software distributed under the License are
//	distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
//	EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
//	INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
//	FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
//	License for the specific language governing rights and limitations
//	under the License.
//
//

	require_once("../../includes/config.inc.php");			// Load config params
	require_once("{$fpconfig['root_path']}/includes/dbconnect.inc.php");		//All the db stuff

	function delete_row($item_id){
		$my_query = "DELETE FROM quickies WHERE q_id = $item_id";
		
		$result = mysql_query($my_query);	
	}
	
	
	function update_row($item_id, $active, $item_text, $item_url){
		if(!get_magic_quotes_gpc()){
			$the_text = addslashes($item_text);
			$the_url = addslashes($item_url);
		} else {
			$the_text = $item_text;
			$the_url = $item_url;
		}
		
		$the_id = $item_id;
		
		if($active) $flag = "active=1";
		else $flag = "active=0";

		$my_query = "UPDATE quickies SET q_title='$the_text', q_link='$the_url', post_date=now(), $flag WHERE q_id=$the_id";
		
		//print $my_query;	
		$result = mysql_query($my_query);
	}
	
	function insert_new_row($item_text, $item_url){
	
		if(!get_magic_quotes_gpc()){
			$the_text = addslashes($item_text);
			$the_url = addslashes($item_url);
		} else {
			$the_text = $item_text;
			$the_url = $item_url;
		}
			
		$my_query = "INSERT INTO quickies (q_id, q_title, q_link, post_date, active) " .
					"VALUES( NULL, '$the_text', '$the_url', now(), 1 )";
		
		$result = mysql_query($my_query);

	}


	function print_total_rec(){
		$my_query = "SELECT count(*) as count FROM quickies ";
			
		$result = mysql_query($my_query);
		
		$row = mysql_fetch_array($result);
		
		$rec_count = $row['count'];
		
		echo "<b>Á`¸ê®Æµ§¼Æ¡G$rec_count</b> ";
		
		if($result) mysql_free_result($result);
	}

	
	function print_items($start, $len, $sort_by){
		global $PHP_SELF;

		$sel_back = "selected";
		$sel_fore = "";
		$where_str = "";
		
		if($start >= 0 && $len > 0){
			$limit_str = "LIMIT 0, $len";
		} else {
			$limit_str ="LIMIT 0, 30";
			$len = 30;
		}
		
		if($sort_by == "backward"){
			if($start) $where_str = "WHERE q_id >= $start ";
			$sel_fore = "selected";
			$order_str = "asc";
		} else {
			$sort_by  = "forward";
			if($start) $where_str = "WHERE q_id <= $start ";
			$sel_back = "selected";
			$order_str = "desc";
		}
		
		$my_query = "SELECT q_id, q_title, q_link, active ".
					"FROM quickies $where_str ".
					"ORDER BY q_id $order_str $limit_str";

		$result = mysql_query($my_query);
		
		if (mysql_num_rows($result) > 0){
			$the_first_row = true;
			$cnt = 0;
			
			while ($row = mysql_fetch_array($result)){
				$r_id = $row['q_id'];
				$r_title = $row['q_title'];
				$r_link = $row['q_link'];				
				($row['active'] > 0) ? $r_active = "checked" :  $r_active = "";
				
				if($cnt == 0) $bg_color="#eaeaea";
				else  $bg_color="#ffffff";
				
				if($the_first_row){
?>				
				<table width="100%" border="0" cellpadding="2" cellspacing="0" >
				<tr><td align="center" bgcolor="#eeeeee" colspan="5"><form action="<? echo $PHP_SELF; ?>" method="post">
				<input type="hidden" name="mode" value="update_view">
				±q <input type="text" name="first_row" value="<? echo $r_id; ?>" size="4" maxlength="3"> ¸¹¬ö¿ý¶}©l 
				<select name="direction" class="form_elements">
				<option value="forward" <? echo $sel_back; ?>>¦V«e</option>
				<option value="backward" <? echo $sel_fore; ?>>¦V«á</option>
				</select> Åã¥Ü¡A¨C¦¸Åã¥Ü <input type="text" name="row_num" value="<? echo $len; ?>" size="4" maxlength="3"> µ§¬ö¿ý¡@
				<input type="submit" name="update_list" value="§ó·s" class="form_elements">
				</form><hr></td></tr>
<?
					$the_first_row = false;
				
				}

?>
				<tr bgcolor="<? echo $bg_color; ?>">
				<td colspan="5"><form action="<? echo $PHP_SELF; ?>" method="post">
				<input type="hidden" name="mode" value="update_row">
				<input type="hidden" name="item_id" value="<? echo $r_id; ?>">
				<input type="hidden" name="first_row" value="<? if($start) echo $start; else echo ""; ?>">
				<input type="hidden" name="row_num" value="<? echo $len; ?>">
				<input type="hidden" name="direction" value="<? echo $sort_by; ?>">
				<table width="100%" border="0" cellpadding="2" cellspacing="2">
				<th class="table_hdr">½s¸¹</th>
				<th class="table_hdr">±i¶K</th>
				<th class="table_hdr">¼Ð ¡@ ÃD</th>
				<th class="table_hdr">Áp ¡@ µ²</th>
				<th></th>
				<tr>
				<td align="center"><? echo $r_id; ?></td>
				<td align="center"><input type="checkbox" name="active" value="1" <? echo $r_active; ?>></td>
				<td><input type="text" size="40" name="item_text" value="<? echo htmlspecialchars($r_title); ?>"></td>
				<td><input type="text" size="40" name="item_url" value="<? echo htmlspecialchars($r_link); ?>"></td>
				<td nowrap><input type="submit" name="update_item" value="§ó·s" class="form_elements"> <input type="submit" name="delete_item" value="§R°£" class="form_elements"></td>
				</tr></table></form>
				</td></tr>
				
<?			
				$cnt = ($cnt+1) % 2;
				
				}

			echo "</table>\n";
		} else {
?>
				<tr><td align="center" bgcolor="#eeeeee" colspan="5"><form action="<? echo $PHP_SELF; ?>" method="post">
				<input type="hidden" name="mode" value="update_view">
				±q <input type="text" name="first_row" value="<? echo $r_id; ?>" size="4" maxlength="3"> ¸¹¬ö¿ý¶}©l 
				<select name="direction" class="form_elements">
				<option value="forward" <? echo $sel_back; ?>>¦V«e</option>
				<option value="backward" <? echo $sel_fore; ?>>¦V«á</option>
				</select> Åã¥Ü¡A¨C¦¸Åã¥Ü <input type="text" name="row_num" value="<? echo $len; ?>" size="4" maxlength="3"> µ§¬ö¿ý¡@
				<input type="submit" name="update_list" value="§ó·s" class="form_elements">
				</form><hr></td></tr>
			<tr><td align="center" bgcolor="#eeeeee"><br><b>¸ê®ÆÄ椺®e¬°ªÅ¥Õ¡C</b><br><br></td></tr>	
		
<?		}
	
		if($result) mysql_free_result($result);

	}
	
	
	function print_footer(){
?>	
	<div class="footer_txt">Copyright &#169; 1996 - 2002 FrostyPlace.com</div>
<?
	}	
?>
Return current item: FPCode