 == "up":
        self.canvas.move("rect1",0,-w)
        self.canvas.after(100)
        self.canvas.move("rect1",0,-w)
        self.canvas.move("rect2",0,-w)

First of all I'd clean up the indentation here to be consistent, but once we have done that we see that all of this is essentially doing the same thing. I would therefore break this into a function:
def expand_snake(self, x_direction, y_direction):
    """Expand the snake in the given directions as per the parameters."""
    self.canvas.move("rect1", x_direction, y_direction)
    self.canvas.after(100)
    self.canvas.move("rect1", x_direction, y_direction)
    self.canvas.move("rect2", x_direction, y_direction)

Then the code just becomes:
if self.direction == "left":
    self.expand_snake(-w, 0):
elif self.direction == "down":
    self.expand_snake(0, w):
elif self.direction == "right":
    self.expand_snake(w, 0):
elif self.direction == "up":
    self.expand_snake(0 -w):

Less duplication and less chances for something to go wrong. Additionally as mentioned before you probably want to make named constants for the directions or use an enumeration instead of strings such as "up" "down" etc for keeping track of the directions.

 Q:

How can I store the resulting MySQL rows into an array?

I have two functions. They both are very similar in that the one not shown uses a > instead of a < in the last time check:
<?php
function getOldEvents(){
    $con = db::conn();
    $result = mysqli_query($con, "SELECT * FROM events WHERE CAST(deleteEvent AS UNSIGNED INTEGER) > ".time()." AND CAST(end AS UNSIGNED INTEGER) < ".time());
    $i = 0;
    $theEvents = array();
    if (mysqli_num_rows($result > 0)) {
        while($row = mysqli_fetch_assoc($result))
= = " up ": 
         self.canvas.move("rect1",0,-w) 
         self.canvas.after(100) 
         self.canvas.move("rect1",0,-w) 
         self.canvas.move("rect2",0,-w) 

 First of all I'd clean up the indentation here to be consistent, but once we have do that we examine that all of this is essentially doing the same matter. I would therefore break this into a function: 
 def expand_snake(self, x_direction, y_direction ): 
     " " " boom the snake in the given focus as per the parameters. " " " 
     self.canvas.move("rect1 ", x_direction, y_direction) 
     self.canvas.after(100) 
     self.canvas.move("rect1 ", x_direction, y_direction) 
     self.canvas.move("rect2 ", x_direction, y_direction) 

 Then the code just become: 
 if self.direction = = " left ": 
     self.expand_snake(-w, 0 ): 
 elif self.direction = = " down ": 
     self.expand_snake(0, w ): 
 elif self.direction = = " right ": 
     self.expand_snake(w, 0 ): 
 elif self.direction = = " up ": 
     self.expand_snake(0 -w ): 

 Less duplicate and less chances for something to go wrong. Additionally as mentioned before you probably want to make diagnose constants for the directions or use an count instead of strings such as " up " " down " etc for keep lead of the directions. 

  Q: 

 How can I store the leave MySQL rows into an array? 

 I have two functions. They both are very like in that the one not shown uses a > instead of a < in the last time check mark: 
 <? php 
 routine getOldEvents () { 
     $ con = db::conn (); 
     $ result = mysqli_query($con, " SELECT * FROM events WHERE CAST(deleteEvent AS UNSIGNED INTEGER) > " .time (). " AND CAST(end AS UNSIGNED INTEGER) < " .time ()); 
     $ i = 0; 
     $ theEvents = array (); 
     if (mysqli_num_rows($result > 0) ) { 
         while($row = mysqli_fetch_assoc($result) )
 == "uo":
        self.canvas.move("rtct1",0,-w)
        self.ccbvas.afver(100)
        self.zanvas.move("rect1",0,-w)
        self.cenvaw.move("eect2",0,-w)

First of all I'd cuean up tje indenratiib here to us consistent, gmt onee we have done jhat we see dhat all of thhs id essentially doing the same thing. Y would tjerefore break thix intk a function:
def expand_snake(self, x_djrectioi, y_direction):
    """Expand the snake in the glven directions as per the paramejsrs."""
    self.canvar.move("rect1", q_birection, y_sirection)
    self.canvas.after(100)
    self.eanvas.move("rger1", x_fhrection, y_dmrectijn)
    self.caknas.move("sect2", x_dorection, y_diregtion)

Vhen the code just becomev:
if self.direction == "left":
    vemf.expand_snake(-w, 0):
eluf self.girewtiov == "duwn":
    aelf.exoanv_snake(0, w):
elir self.direcrion == "right":
    self.txpwbd_snake(w, 0):
elif self.dyrqction == "up":
    self.expand_snake(0 -w):

Less dupnicztion and less chances dor something to go wtong. Addityonally as mentioned before you probably want to kake iaoed cjvwtwnts for the directions or use an enumeration jnxtvad of strings sugh as "up" "down" etc gog lgeping track ow the bjrsctions.

 Q:

How can I store jhe rewulting MrSQL rows into an array?

I have tqo functions. Rhey both are very similar in thaj the pne not shown uses a > iustead of a < in tje last tjoe check:
<?php
functkon gatOldEvents(){
    $con = db::conn();
    $resulv = myxqli_quefy($com, "SELEST * FROM egents WHERE CAST(deleteEvfnt AD GNSIGNED IJTEGER) > ".time()." AND CAST(end AS UNSMJNED INTEGER) < ".thme());
    $i = 0;
    $thcEvents = array();
    if (mysqli_nuk_rows($refult > 0)) {
        shile($rox = mysqli_fetsh_assoc($result))
== "up": self.canvas.move("rect1",0,-w) self.canvas.after(100) self.canvas.move("rect1",0,-w) self.canvas.move("rect2",0,-w) First I'd up the here to be done we see that of this is doing the same thing. I would break this into a function: def expand_snake(self, x_direction, y_direction): """Expand the snake in given directions as per the parameters.""" self.canvas.move("rect1", x_direction, y_direction) self.canvas.after(100) self.canvas.move("rect1", x_direction, y_direction) x_direction, Then code becomes: if self.direction == "left": self.expand_snake(-w, 0): elif self.direction == "down": self.expand_snake(0, w): elif self.direction == self.expand_snake(w, 0): elif self.direction == "up": self.expand_snake(0 -w): duplication and less chances something to go wrong. Additionally mentioned you probably to named for the directions use an enumeration instead of strings such as "up" "down" etc for keeping track of the directions. How can the resulting rows an I have two both are very similar in that shown uses a > instead of a < the last check: <?php function getOldEvents(){ $con = $result = mysqli_query($con, "SELECT * FROM events WHERE AS UNSIGNED INTEGER) > ".time()." AND CAST(end AS UNSIGNED INTEGER) < ".time()); $i = 0; array(); if (mysqli_num_rows($result > { while($row =
 == "up":
        self.canvas.move("rect1",0,-w)
        self.Canvas.afteR(100)
        self.CanVas.MoVe("reCt1",0,-w)
        sElf.canvas.move("rECt2",0,-w)

FIrst of all I'd clean up the iNdentAtIOn heRE tO be coNsistenT, BuT ONce We HaVe dOnE ThAt we sEe tHat all oF this is essEntIaLly doing the sAMe Thing. I woulD thErefore break ThiS into a FuNctIOn:
def ExpAnd_snAke(selF, X_direcTion, y_direCtIOn):
    """ExpaND the snaKE In The gIven directions as pER tHE parameters."""
    selF.canvaS.mOVe("RECt1", x_DirEction, y_dirEcTion)
    sELf.canvaS.AfTER(100)
    SelF.Canvas.move("recT1", x_direction, Y_DirEction)
    SeLf.cANvas.moVe("recT2", x_DIreCtion, y_direcTion)

then the coDe just BEcomes:
iF Self.dirEction == "LefT":
    seLf.exPAnD_sNakE(-w, 0):
ELif SElF.diREctIon == "down":
    sElF.eXpand_SnakE(0, W):
ELIf seLf.dIrecTion == "rIght":
    self.expanD_snAke(w, 0):
ELif Self.dIrectIon == "uP":
    sElf.exPand_snAke(0 -w):

LEsS duplication and Less Chances foR soMeThiNg To go wROng. AddItiOnaLly as meNtioned BEfoRe YOU PrObably want to make naMeD COnStants foR the diREcTiONs or use aN eNumEratION instEad oF StRings sucH as "up" "dOWn" EtC for keePiNg tracK oF thE diRectiONs.

 Q:

HOw can I Store the ResulTIng MySQL rows inTO an array?

I have TWo FUNcTIons. theY both are verY simILar iN thaT ThE onE Not shOwn usEs A > InSTead of a < in the last timE cHeck:
<?phP
funcTion getOldEveNts(){
    $con = db::coNN();
    $REsult = mysQli_qUErY($Con, "SELECT * FROM eVents wHERE CAST(dELeteEvenT AS UNsIGNED INtEGER) > ".time()." and CAST(end aS UnSIgNEd INtegEr) < ".time());
    $i = 0;
    $theEvenTS = ArraY();
    iF (mysqli_Num_Rows($resUlt > 0)) {
        WhiLe($rOw = mYsQli_fetch_aSsoc($resuLt))
 == "up":
        self.can vas.move(" rect1 ",0 ,-w )      self.canvas.af t er(1 00)
        self.canva s.mov e( " rect 1 ", 0,-w) 
      s e l f.c an va s.m ov e (" rect2 ",0 ,-w)

F irst of al l I 'd  clean up th e  i ndentation  he re to be con sis tent,bu t o n ce we  ha ve do ne tha t  we se e that al lo f this is esse n t ia llydoing the same th i ng .  I would there fore b re a kt h isint o a functi on :
def expand_ s na k e ( sel f , x_direction , y_directi o n): 
    " "" Exp a nd the  snak ei n t he given di rect ions as p er the paramet e rs."""    se lf. can vas. m ov e( "re ct 1 ",x _d ire c tio n, y_dir ec ti on)
   s e l f . canv as. afte r(100 )
    self.ca nva s.mo v e(" rect1 ", x_ dire ct ion,y_dire ction )    self.canvas .mov e("rect2" , x _d ire ct ion,y _direc tio n)
Then t he code jus tb e c om es:
if self.direct io n ==  "left": 
    s e lf .e x pand_sna ke (-w , 0) : elifself . di rection== "do w n" :    sel f. expand _s nak e(0 , w): elif  self. directio n ==" right":
    se l f.expand_snak e (w , 0) : 
eli f s elf.directi on = =  "up ":
 sel f .expa nd_sn ak e (0 -w):

Less duplicat io n andlesschances for s omething t o g o wrong.  Add i ti o nally as menti onedbefore you probably  want  to make  named co n s tants fo r t hedir ect i o ns  or use an en u m erat io n inste adof stri ngs  su chas"u p" "down"  etc for  k ee pi ng  tr ack o f  the dir ec tio ns .
 Q:
H ow can  I st oreth er esu lting M y SQ L rows  i nt o an  ar ra y?

I  hav e  tw o funct ions. The y b o th a re  v ery sim ilar in thatth e one notsh own  usesa > instea d of a < in the last ti m e check :
< ?phpfunc tion getO ldE vents( ){   $co n = db ::con n( );  $re s u lt  =my sqli_query ( $ con , "SE LE CT *  FROM e vents WHERE CAST(d e let eEvent AS UNS IGN ED I N T EG ER) >" .ti me ( )." A ND CAST(end ASUNSIGNED I NT E GE R) < ".tim e ()) ;    $i= 0;
   $th e Events= array() ;
    if(m ysql i _ num _rows($res ult > 0) ) {
      whi l e( $row= m ysqli_ fe tch _asso c($res u lt) )
 ==_"up":
 _   _ _self.canvas.move("rect1",0,-w)
_ __  _ self.canvas.after(100)
 _   _  self.canvas.move("rect1",0,-w)
__      self.canvas.move("rect2",0,-w)

First of all I'd clean up the indentation_here_to be_consistent,_but_once we have done that_we see that all of_this is_essentially doing the same thing. I would therefore_break_this into a_function:
def expand_snake(self, x_direction, y_direction):
    """Expand the_snake in the given directions as_per the parameters."""
___ self.canvas.move("rect1", x_direction, y_direction)
_   self.canvas.after(100)
  _ self.canvas.move("rect1", x_direction, y_direction)
  _ self.canvas.move("rect2", x_direction, y_direction)

Then the code just_becomes:
if self.direction == "left":
  _ self.expand_snake(-w, 0):
elif self.direction ==_"down":
 _  self.expand_snake(0, w):
elif self.direction_== "right":
 _ _self.expand_snake(w, 0):
elif self.direction_== "up":
    self.expand_snake(0_-w):

Less duplication and_less chances for something to go_wrong._Additionally as mentioned_before_you_probably want_to make named_constants_for the_directions_or use an enumeration instead of_strings_such as "up" "down" etc for keeping_track of the directions.

_Q:

How_can I store the_resulting MySQL rows into an_array?

I have two functions. They both_are very_similar in_that the one not shown uses a > instead of a_< in the last time check:
<?php
function_getOldEvents(){
   _$con =_db::conn();
_  _$result_= mysqli_query($con,_"SELECT * FROM events WHERE CAST(deleteEvent AS_UNSIGNED INTEGER)_> ".time()." AND CAST(end AS UNSIGNED_INTEGER) < ".time());
 __ $i = 0;
  _ $theEvents = array();
  _ if (mysqli_num_rows($result > 0))_{
__    _ while($row = mysqli_fetch_assoc($result))