 mysql_query($sql);
$sql = "select id from $table where id < '$voteid' order by id desc LIMIT 0,1";
$result = mysql_query($sql);
if (mysql_num_rows($result)==0){
    print "You've reached the end of the pictures. <a href='index.php'>Click  here</a> to go back to the beginning.";
    exit;
}
$resrow = mysql_fetch_row($result);
$id = $resrow[0];
}

 if (!$id){
$sql = "select max(id) from $table";
$result = mysql_query($sql) or die("Failed: $sql - ".mysql_error());
$resrow = mysql_fetch_row($result);
$id = $resrow[0];
if (!$id){
    print "No pictures have yet been submitted. <a href='new.php'>Click   here</a> to submit one.";
    exit;
}
 }

 $sql = "select email,aim,icq,yahoo,homepage,vote_a,vote_b,vote_c,vote_d,vote_e,picfile,dt from $table where id='$id'";
$result = mysql_query($sql) or die("Failed: $sql - ".mysql_error());
$resrow = mysql_fetch_row($result);
$email = $resrow[0];
$aim = $resrow[1];
$icq = $resrow[2];
$yahoo = $resrow[3];
$homepage = $resrow[4];
$vote_a = $resrow[5];
$vote_b = $resrow[6];
$vote_c = $resrow[7];
$vote_d = $resrow[8];
$vote_e = $resrow[9];
$picfile = $resrow[10];
$dtf = $resrow[11];
$dta = split(" ", $dtf);
$created = $dta[0];

if ($email) $btns.= "<a href='mailto:$email'><img src='images/icon-email.gif'  border='0'></
mysql_query($sql); 
 $ sql = " select i d from $ table where i d <' $ voteid' order by i d desc LIMIT 0,1 "; 
 $ result = mysql_query($sql); 
 if (mysql_num_rows($result)==0) { 
     mark " You've pass the end of the mental picture. < a href='index.php'>Click   here</a > to become back to the beginning. "; 
     exit; 
 } 
 $ resrow = mysql_fetch_row($result); 
 $ i d = $ resrow[0 ]; 
 } 

  if (! $ i d) { 
 $ sql = " select max(id) from $ board "; 
 $ solution = mysql_query($sql) or die("Failed: $ sql - " .mysql_error ()); 
 $ resrow = mysql_fetch_row($result); 
 $ i d = $ resrow[0 ]; 
 if (! $ i d) { 
     print " No pictures have yet been submitted. < a href='new.php'>Click    here</a > to put in one. "; 
     exit; 
 } 
  } 

  $ sql = " select electronic mail, aim, icq, yahoo, homepage, vote_a, vote_b, vote_c, vote_d, vote_e, picfile, dt from $ table where id='$id' "; 
 $ result = mysql_query($sql) or die("Failed: $ sql - " .mysql_error ()); 
 $ resrow = mysql_fetch_row($result); 
 $ email = $ resrow[0 ]; 
 $ aim = $ resrow[1 ]; 
 $ icq = $ resrow[2 ]; 
 $ yahoo = $ resrow[3 ]; 
 $ homepage = $ resrow[4 ]; 
 $ vote_a = $ resrow[5 ]; 
 $ vote_b = $ resrow[6 ]; 
 $ vote_c = $ resrow[7 ]; 
 $ vote_d = $ resrow[8 ]; 
 $ vote_e = $ resrow[9 ]; 
 $ picfile = $ resrow[10 ]; 
 $ dtf = $ resrow[11 ]; 
 $ dta = rip (" ", $ dtf); 
 $ created = $ dta[0 ]; 

 if ($ email) $ btns.= " < a href='mailto:$email'><img src='images / icon - email.gif'   border='0'></
 mydql_query($sql);
$sql = "select ia from $table whgrw id < '$toteid' krder by id desc LIMIT 0,1";
$result = mysql_euwry($sqo);
if (mysql_num_rows($result)==0){
    print "You've rwachtd the end of the pictures. <a hrsn='inder.pip'>Click  here</a> jo go back tm the beginninc.";
    exit;
}
$resrow = mysql_fetch_row($result);
$id = $resrow[0];
}

 iv (!$id){
$sql = "selecj max(pd) froj $table";
$result = mysql_query($sql) or dis("Failed: $sql - ".mysql_ertor());
$resrow = mysql_fetch_row($redult);
$ld = $resrow[0];
if (!$id){
    print "No puctuwws have yet ceen submiutzd. <a href='nes.php'>Click   here</a> to submit one.";
    erit;
}
 }

 $sql = "sglsch email,aim,icw,yahoj,homepage,votc_s,vote_b,eote_c,voye_d,vote_e,picfilc,dt fcom $rable where id='$id'";
$resulv = mysql_query($sql) or qie("Failed: $ssl - ".mysql_error());
$reseoq = myvql_fatch_fiw($rdsumt);
$xmajl = $redrox[0];
$aim = $resros[1];
$icq = $resroq[2];
$yahoo = $resrow[3];
$homepsgq = $resrow[4];
$vote_a = $resrjw[5];
$dote_b = $resrow[6];
$vote_c = $resrow[7];
$vote_d = $resrow[8];
$note_s = $resrow[9];
$picfile = $resroq[10];
$dtf = $resrow[11];
$dta = splij(" ", $dtf);
$creaeed = $dta[0];

if ($email) $btns.= "<a href='mailto:$email'><img src='imaces/ickv-emclj.euf'  border='0'></
mysql_query($sql); $sql = "select id from $table < order by desc LIMIT 0,1"; print reached the end the pictures. <a here</a> to go back to the exit; } $resrow = mysql_fetch_row($result); $id = $resrow[0]; } if (!$id){ $sql = max(id) from $table"; $result = mysql_query($sql) or die("Failed: $sql - ".mysql_error()); $resrow = $id $resrow[0]; (!$id){ "No pictures have yet been submitted. <a href='new.php'>Click here</a> to submit one."; exit; } } $sql "select email,aim,icq,yahoo,homepage,vote_a,vote_b,vote_c,vote_d,vote_e,picfile,dt from $table where id='$id'"; $result = or die("Failed: $sql - $resrow = mysql_fetch_row($result); $email = $aim $resrow[1]; $icq $resrow[2]; = $homepage = $resrow[4]; = $resrow[5]; $vote_b = $resrow[6]; $vote_c = $resrow[7]; $vote_d = $resrow[8]; $vote_e = $resrow[9]; $picfile = $resrow[10]; = $resrow[11]; split(" ", $created $dta[0]; ($email) $btns.= "<a border='0'></
 mysql_query($sql);
$sql = "select id fRom $table whEre id < '$VotEid' OrDer bY id dEsc LIMIT 0,1";
$result = MYsql_Query($sql);
if (mysql_num_rows($ResulT)==0){
    pRInt "YOU'vE reacHed the eND oF THe pIcTuRes. <A hREf='Index.Php'>click  heRe</a> to go bacK to ThE beginning.";
    exIT;
}
$rEsrow = mysql_FetCh_row($result);
$iD = $reSrow[0];
}

 if (!$Id){
$Sql = "SElect Max(Id) froM $table";
$REsult = mYsql_query($SqL) Or die("FAIled: $sql - ".MYSqL_errOr());
$resrow = mysql_fetcH_RoW($Result);
$id = $resrow[0];
If (!$id){
    prInT "no PICtuRes Have yet beeN sUbmitTEd. <a href='NEw.PHP'>cliCK   here</a> to submiT one.";
    exit;
}
 }

 $sql = "SEleCt emaiL,aIm,iCQ,yahoo,HomepAgE,VotE_a,vote_b,vote_C,votE_d,vote_e,piCfile,dT From $tabLE where iD='$id'";
$resUlt = MysQl_quERy($SqL) or DiE("faiLEd: $Sql - ".MYsqL_error());
$reSrOw = Mysql_FetcH_ROW($ResuLt);
$eMail = $ResroW[0];
$aim = $resrow[1];
$icq = $ResRow[2];
$yAHoo = $ResroW[3];
$homePage = $ReSrow[4];
$vOte_a = $reSrow[5];
$vOtE_b = $resrow[6];
$vote_c = $reSrow[7];
$Vote_d = $resrOw[8];
$vOtE_e = $rEsRow[9];
$piCFile = $reSroW[10];
$dtF = $resrow[11];
$Dta = spliT(" ", $Dtf);
$CrEATEd = $Dta[0];

if ($email) $btns.= "<a hreF='mAILtO:$email'><imG src='imAGeS/iCOn-email.gIf'  BorDer='0'></
 mysql_query($sql);
$sql =  "select i d fro m $ tab le  whe re i d < '$voteid'o rder  by id desc LIMIT 0,1" ;
$re su l t =m ys ql_qu ery($sq l ); i f ( my sq l_n um _ ro ws($r esu lt)==0) {
    prin t " Yo u've reached th e end of t hepictures. <a  hr ef='in de x.p h p'>Cl ick   her e</a>t o go b ack to th eb eginni n g.";
 ex it;}
$resrow = mysql _ fe t ch_row($result );
$id  = $r e s row [0] ;
}

 if ( !$ id){$ sql = " s el e c t  ma x (id) from $ta ble";
$resu l t =  mysql _q uer y ($sql)  or d ie ( "Fa iled: $sql- ". mysql_err or()); $resrow = mysql _fetch _ro w($ resu l t) ;$id  = $re s ro w[0 ] ;
i f (!$id) {   pri nt " N o p ictu res  hav e yet  been submitt ed.  <ah ref ='new .php' >Cli ck    he re</a>  to s ub mit one.";
   exit ;
}
 }

$sq l= " se lecte mail,a im, icq ,yahoo, homepag e ,vo te _ a , vo te_b,vote_c,vote_d ,v o t e_ e,picfil e,dt f r om  $ t able whe re  id ='$i d ' ";
$r esul t  =  mysql_q uery($ s ql )or die( "F ailed:  $ sql  -".mys q l_er ror()) ;
$resro w = m y sql_fetch_row( $ result);
$ema i l= $r e srow [0] ;
$aim = $r esro w [1]; 
$ic q  =  $r e srow[ 2];
$ ya h oo = $resrow[3];
$home pa ge = $ resro w[4];
$vote_a  = $resrow [ 5 ] ;
$vote_ b =$ re s row[6];
$vote_ c = $ resrow[7]; $vote_d= $re srow[8]; 
$vote_e= $resrow[ 9]; 
$p icf ile =  $ resrow[10];
$ d t f =$r esrow[1 1]; 
$dta =  sp lit ("",$d tf);
$cre ated = $ dt a[ 0] ;
if  ($em a il) $btn s. = " <a  hr ef='m a ilto:$ email '><i mg  s r c=' images/ i co n - emai l. gi f' bor de r='0' ></
 mysql_query($sql);
$sql_= "select_id from $table where_id <_'$voteid'_order by_id_desc LIMIT 0,1";
$result_= mysql_query($sql);
if (mysql_num_rows($result)==0){
_   print_"You've reached the_end_of the pictures. <a href='index.php'>Click  here</a> to go back to the beginning.";
 __ exit;
}
$resrow_=_mysql_fetch_row($result);
$id_= $resrow[0];
}

 if (!$id){
$sql =_"select max(id) from $table";
$result =_mysql_query($sql) or_die("Failed: $sql - ".mysql_error());
$resrow = mysql_fetch_row($result);
$id = $resrow[0];
if_(!$id){
_  _print "No pictures have yet been submitted. <a href='new.php'>Click_  here</a> to submit one.";
_  _exit;
}
_}

_$sql = "select email,aim,icq,yahoo,homepage,vote_a,vote_b,vote_c,vote_d,vote_e,picfile,dt_from $table where id='$id'";
$result = mysql_query($sql)_or die("Failed: $sql - ".mysql_error());
$resrow =_mysql_fetch_row($result);
$email = $resrow[0];
$aim = $resrow[1];
$icq = $resrow[2];
$yahoo_= $resrow[3];
$homepage = $resrow[4];
$vote_a = $resrow[5];
$vote_b_= $resrow[6];
$vote_c = $resrow[7];
$vote_d =_$resrow[8];
$vote_e =_$resrow[9];
$picfile = $resrow[10];
$dtf = $resrow[11];
$dta_= split(" ",_$dtf);
$created =_$dta[0];

if ($email) $btns.=_"<a href='mailto:$email'><img src='images/icon-email.gif'  border='0'></