 pero resulta que al momento de correr mostrar por primera vez mi tabla me borra todos los registros sin ni siquiera haber hecho click
 pero resulta que al momento de correr mostrar por primera vez mi tabla me borra todos los registros sin ni siquiera haber hecho click  .
.Agradezco la atención y espero que alguien pueda ayudarme
Esta es mi función
Código PHP:
   function ElimCita($CitaID)
{
    global $central;
    $queryDel = "delete from citas where cvecita = '". $CitaID . "'";
    $queryExecDel = mysql_query($queryDel, $central) or die (mysql_error());
    $DeletedRecords = mysql_affected_rows();
    if ($DeletedRecords > 0){
            echo "<script type=\"text/javascript\">\n";
            echo "alert(\"Se borró correctamente \" + $namedoc + ' registro');\n";
            echo "</script>\n";
    }
    else{
            echo "<script type=\"text/javascript\">\n";
            echo "alert('La acción no se ejecutó correctamente');\n";
            echo "</script>\n";    
    }
} 
    Y esta es mi tabla
Código HTML:
 <table> <tr> </tr> <tr> <td height="134" colspan="2"> <div class="Estilo2"> <?php if ($totalRows_citas == 0) { echo 'No hay citas registradas para este día'; } else {?></div> <table width="1050" border="1" align="center"> <tr class="Estilo2"> <td align="center" width="120">Doctor</td> <td align="center" width="120">Paciente</td> <td align="center" width="80">Fecha </td> <td align="center" width="60">Hora</td> <td align="center" width="167">Observaciones</td> <td align="center" width="80">Opciones</td> </tr> <?php do { ?> //Y aqui voy llenando mi tabla con los registros <tr class="Estilo3"> <td><?php echo $row_citas['doctor']; ?></td> <td><?php echo $row_citas['paciente']; ?></td> <td align="center"><?php echo $row_citas['fecha_cita']; ?></td> <td align="center"><?php echo $row_citas['hora']; ?></td> <td><?php if ($row_citas['observaciones'] != '') echo $row_citas['observaciones']; else echo " - - - "; ?></td> <td align="center"> <table width="73" border="0"> <tr> <td align="center" ><a href="Cita-Modificacion.php?recordID=<?php echo $row_citas['cvecita']; ?>"><img src="imagenes/lapiz.JPG" width="21" height="22" border="0" alt="Editar"></a></td> <td align="center" ><a href="Cita-Detalles.php?recordID=<?php echo $row_citas['cvecita']; ?>"><img src="imagenes/detalles.JPG" width="22" height="22" alt="Detalles" border="0"></a></td> <!-- Aqui es donde deseo que al momento de hacer click, el usuario pueda eliminarse el registro--> <td align="center" ><img src="imagenes/cancelar.JPG" width="16" height="16" alt="Detalles" border="0" onClick="<?php ElimCita($row_citas['cvecita']); ?>"></td> </tr> </table>
 
 



