Jump to content

Moving a Table


fenzo666

Recommended Posts

Here is the table I want to move: http://db.pokesav.org/ I am moving to a new root folder as well as a new site layout. I want to bring the tables along. There is a table for each Pokemon organized by letter and by generation, as well as an "all pokemon" table. Which part of the code would I need to copy and paste into the new page? (Note: I ONLY want the code for the tables, not the site layout and sidebars, headings, etc.)Thanks!

CODE:

<?php

$querystring = $_SERVER['QUERY_STRING'];
list($sortby, $sortbyletter) = split(':', $querystring);
$set = '';
if ($sortby == '') 
{	
$header = '<li class="selected"> <a href="index.php?:A">numb.</a></li><li><a href="index.php?name:A">Name</a></li>';
$sortby = 'numb';
$set = 'y';
}
if ($sortby == 'name')
{	
$header = '<li><a href="index.php?:A">numb.</a></li><li class="selected"><a href="index.php?name:A">Name</a></li>';	
$set = 'y';
}
if ($sortby == 'missing') 
{	
$header = '<li><a href="index.php?:A">numb.</a></li><li><a href="index.php?name:A">Name</a></li>';
$set = 'y';
}
if ($set != 'y') 
{	
echo 'The variable at the end of the web address did not match one required by the code. Please check the web address for errors.';
exit;
}
$sortbyletter = strtolower($sortbyletter);

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>The PKM Database</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="description" content="An extensive Pokemon file database, including hundreds of events and an upload bin." />
<meta name="keywords" content="pokemon,database,pkm,pokesav,event,wonder card,wondercard,iritegood,fenzo" />
<link rel="stylesheet" href="include/style.css" type="text/css" media="screen,projection" />
</head>

<body>
<?php

include("include/header.php");

?>

<div id="container" ><div id="header">
<h1>The PKM Database</h1>
<h2>
<?php

$randtext[] = "[slogan here]!";
$randtext[] = "Where Pokémon meet Pokésav!";
$randtext[] = "A collector's heaven.";
$randtext[] = "These PKM files have hex data!";

srand ((double) microtime() * 1000000);
$randomtext = rand(0,count($randtext)-1);

echo $randtext[$randomtext];

?>
</h2></div><div id="navigation">
<ul>
<?php echo $header.""; ?><li><a href="event.php">Events</a></li><li><a href="video.php">Videos</a></li><li><a href="other.php">Other</a></li><li><a href="help.php">Help</a></li><li><a href="about.php">About</a></li><li><a href="/upload">Upload</a></li></ul></div><div id="content">

<?php 
if ($sortby == 'name')
{
echo'<h2><h2 align=center><font color="#467AA7"><b>Alphabetical</b></font></h2></h2>';
}

if ($sortby == 'numb')
{
echo'<h2><h2 align=center><font color="#467AA7"><b>Numerical</b></font></h2></h2>';
}
?>

<table summary="List of fields"><tr><th></th><th>#</th><th>Name</th><th>Type</th></tr>

<?php 
$fp = fopen('include/database.csv','r');
if (!$fp)
{
echo 'ERROR: Unable to open file.</table></body></html>'; 
exit;
}
$row = 1;
while (!feof($fp)) 
{	
$line = fgets($fp,1024); //use 2048 if very long lines	
$row++;	
list ($numb, $name, $type1, $type2) = split ('\,', $line);	
if ($sortby == 'numb') $sortkey = strtolower($numb);	
if ($sortby == 'name') $sortkey = strtolower($name);	
$col[$row] = array($sortkey, $numb, $name, $type1, $type2);
}
fclose($fp);
sort($col);
reset ($col);
$arrays = count($col) - 1;
$loop = -1;
$loopcounter = 0;/********** Function for sorting by number **********/
if ($sortby == 'numb')
{
echo '<p class="textcenter"><a href="index.php?:A">I</a> | <a href="index.php?:B">II</a> | <a href="index.php?:C">III</a> | <a href="index.php?">IV</a> | <a href="index.php?:E">All</a></p>';
if ($sortbyletter == 'a')
{
$startingnumber = 001;
$endingnumber = 151;
}
elseif ($sortbyletter == 'b')
{
$startingnumber = 152;
$endingnumber = 251;
}
elseif ($sortbyletter == 'c')
{
$startingnumber = 252;
$endingnumber = 386;
}
elseif ($sortbyletter == 'd')
{
$startingnumber = 387;
$endingnumber = 493;
}
elseif ($sortbyletter == 'e')
{
$startingnumber = 001;
$endingnumber = 493;
}
else 
{
$startingnumber = 001;
$endingnumber = 151;
}
while ($loopcounter < $endingnumber) 
{
$loopcounter++;
$loop++;	
if ($loopcounter >= $startingnumber) 
{	
echo '<tr>';//name of pokemon is second column
$nameofpoke = $col[$loop][2];//name of pokemon is lowercased
$nameofpoke = strtolower($nameofpoke);//name of the file is directory+filename
$nameoffile = 'files/pkm/'.$nameofpoke.'.pkm';
$nameoffile2 = 'files/pkm/'.ucwords($nameofpoke).'.pkm';//type 1 is column 3
$typename1 = strtolower($col[$loop][3]);//remove spaces from type1
$typename1 = str_replace ( ' ', "", $typename1);//type 2 is column 4
$typename2 = strtolower($col[$loop][4]);//remove new-lines from column 4
$typename2 = str_replace ( '', "", $typename2);//img tag for type1
$typeimage = '<img alt="type icon" src="include/image/'.$typename1.'.gif" />';//url of second type
$type2url = 'include/image/'.$typename2.'.gif';//checks if the pkm file exists
if (file_exists($nameoffile) || file_exists($nameoffile2)) 
{//if it does...
echo //1 is Poke #, 2 is Poke Name, 3 is Generation
'<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td><a href="'.$nameoffile.'">'.$col[$loop][2].'</a></td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';
}
else 
{
echo '</td></tr>  ';
}
}//zipfiles
elseif (file_exists("files/pkm/".$nameofpoke.".zip")) 
{
echo '<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td><a href="files/pkm/'.$nameofpoke.'.zip">'.$col[$loop][2].'</a></td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';
}
else 
{
echo '</td></tr>';
}
}//same thing but only if there is no file
else 
{
echo '<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td>'.$col[$loop][2].'</td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';
}
else 
{
echo '</td></tr>';
}
}}}}
/********** Function for sorting by name **********/
if ($sortby == 'name') 
{
echo '<div style="text-align:center;"><a href="index.php?name:A">A</a><a href="index.php?name:B">B</a><a href="index.php?name:C">C</a><a href="index.php?name:D">D</a><a href="index.php?name:E">E</a><a href="index.php?name:F">F</a><a href="index.php?name:G">G</a><a href="index.php?name:H">H</a><a href="index.php?name:I">I</a><a href="index.php?name:J">J</a><a href="index.php?name:K">K</a><a href="index.php?name:L">L</a><a href="index.php?name:M">M</a><a href="index.php?name:N">N</a><a href="index.php?name:O">O</a><a href="index.php?name:P">P</a><a href="index.php?name:Q">Q</a><a href="index.php?name:R">R</a><a href="index.php?name:S">S</a><a href="index.php?name:T">T</a><a href="index.php?name:U">U</a><a href="index.php?name:V">V</a><a href="index.php?name:W">W</a><a href="index.php?name:X">X</a><a href="index.php?name:Y">Y</a><a href="index.php?name:Z">Z</a> | <a href="index.php?name">All</a></div><br />';
while ($loop < $arrays) 
{	
$loop++;// Outputs the name of the pokemon and the name of the directory+nameofpokemon uncaptilized+.pkm//name of pokemon is second column
$nameofpoke = $col[$loop][2];$nameofpoke = strtolower($nameofpoke);//name fo the file is directory+filename
$nameoffile = 'files/pkm/'.$nameofpoke.'.pkm';//type 1 is column 3
$typename1 = strtolower($col[$loop][3]);
$typename1 = str_replace ( ' ', "", $typename1);//type 2 is column 4
$typename2 = strtolower($col[$loop][4]);
$typename2 = str_replace ( '', "", $typename2);//img tag for type1
$typeimage = '<img alt="type icon" src="include/image/'.$typename1.'.gif" />';//url of second type
$type2url = 'include/image/'.$typename2.'.gif';
$firstletter = $nameofpoke{0};
if ($firstletter == $sortbyletter) 
{	
echo '<tr>';//checks if the file exists
$nameoffile2 = 'files/pkm/'.ucwords($nameofpoke).'.pkm';
if (file_exists($nameoffile) || file_exists($nameoffile2)) 
{//if it does...
echo //1 is Poke #, 2 is Poke Name, 3 is Generation
'<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td><a href="'.$nameoffile.'">'.$col[$loop][2].'</a></td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';
}
else 
{
echo '</td></tr>';
}}//zipfiles
elseif (file_exists("files/pkm/".$nameofpoke.".zip") || file_exists("files/pkm/".ucwords($nameofpoke).".zip")) 
{
echo'<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td><a href="files/pkm/'.$nameofpoke.'.zip">'.$col[$loop][2].'</a></td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';}else {echo '</td></tr>';
}}
else 
{//same thing but only if there is no file
echo '<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td>'.$col[$loop][2].'</td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';
}
else 
{
echo '</td></tr>';
}}}}}
if ($sortby == 'missing') 
{
while ($loop < $arrays) 
{	
$loop++;// Outputs the name of the pokemon and the name of the directory+nameofpokemon uncaptilized+.pkm//name of pokemon is second column
$nameofpoke = $col[$loop][2];
$nameofpoke = strtolower($nameofpoke);//name fo the file is directory+filename
$nameoffile = 'files/pkm/'.$nameofpoke.'.pkm';//type 1 is column 3
$typename1 = strtolower($col[$loop][3]);
$typename1 = str_replace ( ' ', "", $typename1);//type 2 is column 4
$typename2 = strtolower($col[$loop][4]);
$typename2 = str_replace ( '', "", $typename2);//img tag for type1
$typeimage = '<img alt="type icon" src="include/image/'.$typename1.'.gif" />';//url of second type
$type2url = 'include/image/'.$typename2.'.gif';
$firstletter = $nameofpoke{0};//checks if the file exists
if (file_exists($nameoffile)) {}
else{
echo '<tr>';//same thing but only if there is no file
echo '<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td>'.$col[$loop][2].'</td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';}else {echo '</td></tr>';
}}}}
?></table><br /></div>
<?php include("include/sidebar.php"); 
?>
<div id="footer"><p>
<?php
$year = date("Y",time ()); if ( $year != "2008" ) {echo "© 2008 - ".$year;}else {echo "© 2008";}
?> 
<a href="#">Bao Trinh</a> | Last updated: 
<?php echo date('j F Y', getlastmod());

?>
</p>
</div>
</div>
</body>
</html>

Link to comment
https://forums.phpfreaks.com/topic/128449-moving-a-table/
Share on other sites

This is the table code:

<table summary="List of fields"><tr><th></th><th>#</th><th>Name</th><th>Type</th></tr>

<?php
$fp = fopen('include/database.csv','r');
if (!$fp)
{
echo 'ERROR: Unable to open file.</table></body></html>';
exit;
}
$row = 1;
while (!feof($fp))
{   
$line = fgets($fp,1024); //use 2048 if very long lines   
$row++;   
list ($numb, $name, $type1, $type2) = split ('\,', $line);   
if ($sortby == 'numb') $sortkey = strtolower($numb);   
if ($sortby == 'name') $sortkey = strtolower($name);   
$col[$row] = array($sortkey, $numb, $name, $type1, $type2);
}
fclose($fp);
sort($col);
reset ($col);
$arrays = count($col) - 1;
$loop = -1;
$loopcounter = 0;/********** Function for sorting by number **********/
if ($sortby == 'numb')
{
echo '<p class="textcenter"><a href="index.php?:A">I</a> | <a href="index.php?:B">II</a> | <a href="index.php?:C">III</a> | <a href="index.php?">IV</a> | <a href="index.php?:E">All</a></p>';
if ($sortbyletter == 'a')
{
$startingnumber = 001;
$endingnumber = 151;
}
elseif ($sortbyletter == 'b')
{
$startingnumber = 152;
$endingnumber = 251;
}
elseif ($sortbyletter == 'c')
{
$startingnumber = 252;
$endingnumber = 386;
}
elseif ($sortbyletter == 'd')
{
$startingnumber = 387;
$endingnumber = 493;
}
elseif ($sortbyletter == 'e')
{
$startingnumber = 001;
$endingnumber = 493;
}
else
{
$startingnumber = 001;
$endingnumber = 151;
}
while ($loopcounter < $endingnumber)
{
$loopcounter++;
$loop++;   
if ($loopcounter >= $startingnumber)
{   
echo '<tr>';//name of pokemon is second column
$nameofpoke = $col[$loop][2];//name of pokemon is lowercased
$nameofpoke = strtolower($nameofpoke);//name of the file is directory+filename
$nameoffile = 'files/pkm/'.$nameofpoke.'.pkm';
$nameoffile2 = 'files/pkm/'.ucwords($nameofpoke).'.pkm';//type 1 is column 3
$typename1 = strtolower($col[$loop][3]);//remove spaces from type1
$typename1 = str_replace ( ' ', "", $typename1);//type 2 is column 4
$typename2 = strtolower($col[$loop][4]);//remove new-lines from column 4
$typename2 = str_replace ( '', "", $typename2);//img tag for type1
$typeimage = '<img alt="type icon" src="include/image/'.$typename1.'.gif" />';//url of second type
$type2url = 'include/image/'.$typename2.'.gif';//checks if the pkm file exists
if (file_exists($nameoffile) || file_exists($nameoffile2))
{//if it does...
echo //1 is Poke #, 2 is Poke Name, 3 is Generation
'<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td><a href="'.$nameoffile.'">'.$col[$loop][2].'</a></td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';
}
else
{
echo '</td></tr>  ';
}
}//zipfiles
elseif (file_exists("files/pkm/".$nameofpoke.".zip"))
{
echo '<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td><a href="files/pkm/'.$nameofpoke.'.zip">'.$col[$loop][2].'</a></td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';
}
else
{
echo '</td></tr>';
}
}//same thing but only if there is no file
else
{
echo '<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td>'.$col[$loop][2].'</td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';
}
else
{
echo '</td></tr>';
}
}}}}
/********** Function for sorting by name **********/
if ($sortby == 'name')
{
echo '<div style="text-align:center;"><a href="index.php?name:A">A</a><a href="index.php?name:B">B</a><a href="index.php?name:C">C</a><a href="index.php?name:D">D</a><a href="index.php?name:E">E</a><a href="index.php?name:F">F</a><a href="index.php?name:G">G</a><a href="index.php?name:H">H</a><a href="index.php?name:I">I</a><a href="index.php?name:J">J</a><a href="index.php?name:K">K</a><a href="index.php?name:L">L</a><a href="index.php?name:M">M</a><a href="index.php?name:N">N</a><a href="index.php?name:O">O</a><a href="index.php?name:P">P</a><a href="index.php?name:Q">Q</a><a href="index.php?name:R">R</a><a href="index.php?name:S">S</a><a href="index.php?name:T">T</a><a href="index.php?name:U">U</a><a href="index.php?name:V">V</a><a href="index.php?name:W">W</a><a href="index.php?name:X">X</a><a href="index.php?name:Y">Y</a><a href="index.php?name:Z">Z</a> | <a href="index.php?name">All</a></div><br />';
while ($loop < $arrays)
{   
$loop++;// Outputs the name of the pokemon and the name of the directory+nameofpokemon uncaptilized+.pkm//name of pokemon is second column
$nameofpoke = $col[$loop][2];$nameofpoke = strtolower($nameofpoke);//name fo the file is directory+filename
$nameoffile = 'files/pkm/'.$nameofpoke.'.pkm';//type 1 is column 3
$typename1 = strtolower($col[$loop][3]);
$typename1 = str_replace ( ' ', "", $typename1);//type 2 is column 4
$typename2 = strtolower($col[$loop][4]);
$typename2 = str_replace ( '', "", $typename2);//img tag for type1
$typeimage = '<img alt="type icon" src="include/image/'.$typename1.'.gif" />';//url of second type
$type2url = 'include/image/'.$typename2.'.gif';
$firstletter = $nameofpoke{0};
if ($firstletter == $sortbyletter)
{   
echo '<tr>';//checks if the file exists
$nameoffile2 = 'files/pkm/'.ucwords($nameofpoke).'.pkm';
if (file_exists($nameoffile) || file_exists($nameoffile2))
{//if it does...
echo //1 is Poke #, 2 is Poke Name, 3 is Generation
'<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td><a href="'.$nameoffile.'">'.$col[$loop][2].'</a></td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';
}
else
{
echo '</td></tr>';
}}//zipfiles
elseif (file_exists("files/pkm/".$nameofpoke.".zip") || file_exists("files/pkm/".ucwords($nameofpoke).".zip"))
{
echo'<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td><a href="files/pkm/'.$nameofpoke.'.zip">'.$col[$loop][2].'</a></td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';}else {echo '</td></tr>';
}}
else
{//same thing but only if there is no file
echo '<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td>'.$col[$loop][2].'</td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';
}
else
{
echo '</td></tr>';
}}}}}
if ($sortby == 'missing')
{
while ($loop < $arrays)
{   
$loop++;// Outputs the name of the pokemon and the name of the directory+nameofpokemon uncaptilized+.pkm//name of pokemon is second column
$nameofpoke = $col[$loop][2];
$nameofpoke = strtolower($nameofpoke);//name fo the file is directory+filename
$nameoffile = 'files/pkm/'.$nameofpoke.'.pkm';//type 1 is column 3
$typename1 = strtolower($col[$loop][3]);
$typename1 = str_replace ( ' ', "", $typename1);//type 2 is column 4
$typename2 = strtolower($col[$loop][4]);
$typename2 = str_replace ( '', "", $typename2);//img tag for type1
$typeimage = '<img alt="type icon" src="include/image/'.$typename1.'.gif" />';//url of second type
$type2url = 'include/image/'.$typename2.'.gif';
$firstletter = $nameofpoke{0};//checks if the file exists
if (file_exists($nameoffile)) {}
else{
echo '<tr>';//same thing but only if there is no file
echo '<td><img alt="pokemon icon" src="include/icons/'.$col[$loop][1].'.png" /></td><td>'.$col[$loop][1].'</td><td>'.$col[$loop][2].'</td><td>'.$typeimage;
if (file_exists('include/image/'.$typename2.'.gif'))
{
echo '<img alt="type icon" src="include/image/'.$typename2.'.gif" /></td></tr>';}else {echo '</td></tr>';
}}}}
?></table>

 

This is the error: ERROR: Unable to open file.

# Name Type

Link to comment
https://forums.phpfreaks.com/topic/128449-moving-a-table/#findComment-665681
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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