All pastes #750427 Raw Edit

Miscellany

public text v1 · immutable
#750427 ·published 2007-10-26 14:34 UTC
rendered paste body
public function pagination( $table, $limit, $page, $show )
		{					
			if ( isset( $show ) )
			{
				if ( is_numeric( $show ) )
					$query = "SELECT * FROM `" . $table . "` ORDER BY `ID` LIMIT " . $show . "";
				else
					$query = "SELECT * FROM `" . $table . "` ORDER BY `ID`";
					
				$result = mysql_query( $query );
					
					$fieldnameQuery  = "SHOW COLUMNS FROM `" . $table . "`";
					$fieldnameResult = mysql_query( $fieldnameQuery );
						
					if ( mysql_num_rows( $fieldnameResult ) > 0 )
					{				
						while ( $fields = mysql_fetch_array( $fieldnameResult ) )
						{
							$array_return[$fields['Field']] = array();
							
							while ( $row = mysql_fetch_assoc( $result ) )
							{
								array_push( $array_return[$fields['Field']], $row[$fields['Field']] );
							}
						}	
					}
			}
			return array( $array_return );
		}