function getOnePhotoRandom($idalbum) { $sql = "SELECT * FROM photos WHERE idalbum=" . $idalbum; $rs = DataBase::ExecuteQuery($sql, "ARRAY"); $ph = $rs[array_rand($rs, 1)]; $this->setPhoto($ph['idphoto'], $ph['name'], $ph['src'], $ph['title'], $ph['idalbum'], $ph['fecha']); }
public static function Render($qry, $list, $orderby, $tampag = 50, $pag){ $original_qry = $qry; $qry = GridSortPage::SortQuery($qry, $orderby); $qry = GridSortPage::PaginateQuery($qry, $pag, $tampag); $matrix = DataBase::ExecuteQuery($qry); $html = "\n<table>\n"; $html .= GridSortPage::GetHeader($qry); foreach($matrix as $key => $rows){ $html .= "<tr>"; foreach($rows as $index => $column){ if($key%2 == 0) $html .= "<td>".$column."</td>"; else $html .= "<td class=\"selectedRow\">".$column."</td>"; } #============================================================================ #============================================================================ #------- $html .= "<td>"; if(isset($has_header) && $key == 0){ $html .= "Opciones"; }else{ /*$html .= "<ul id=\"sddm\"> <li> <a href=\"#\" onmouseover=\"mopen('m$key')\" onmouseout=\"mclosetime()\">Opciones</a> <div id=\"m$key\" onmouseover=\"mcancelclosetime()\" onmouseout=\"mclosetime()\">";*/ foreach($list as $url) { if(get_class($url)=='HTMLCheckBox') $html.=$url->fillfromColumn($rows,"msgs[]",0)."\n"; else $html .= $url->Render($rows)."\n"; } $html .= "</div> </li> </ul> <div style=\"clear:both\"></div>"; } $html .= "</td>"; #------- $html .= "\n</tr>\n"; if(isset($has_header) && $key ==0) $html .= "</thead>"; } $html .= "</table>\n"; $html .= GridSortPage::GetNavigationControlsHTML($original_qry, $tampag, $orderby); return $html; } #GetHTMLTable
public static function getOneAlbum($idalbum) { $ab = null; $sql = "SELECT a.idalbum, a.descripcion, COUNT(1) nophotos, a.fecha\r\n\t\tFROM albums a, photos p \r\n\t\tWHERE a.idalbum=p.idalbum\r\n\t\tAND a.idalbum=" . $idalbum . "\r\n\t\tGROUP BY a.idalbum, a.descripcion, a.fecha"; $rs = DataBase::ExecuteQuery($sql, "ARRAY"); //if(count($rs)>0) $ab = new Album($rs[0]['idalbum'], $rs[0]['descripcion'], $rs[0]['nophotos'], $rs[0]['fecha']); return $ab; }
public static function Login ($login_name, $pass, $redirect) { $md5pass = md5($pass); $user_exists = DataBase::ExecuteScalar("SELECT count(1) FROM users WHERE login = '******' AND password = '******'"); if($user_exists == 1){ $qry = "SELECT * FROM users WHERE login = '******' AND password = '******'"; //echo $qry; $row = DataBase::ExecuteQuery($qry); $_SESSION["user"] = new User($row[0][0], $row[0][1], $row[0][2], $row[0][3], $row[0][4], $row[0][5]); //print_r($row); #----------------------------- echo "<script>window.location = '$redirect'</script>"; }else{ echo "Nombre de Usuario y Contraseña no coinciden, Favor de reintentar."; } }
public static function Load(&$object, $sql) { $results = DataBase::ExecuteQuery($sql, "ARRAY"); $keys = array_keys($results[0]); $string_keys = array(); foreach($keys as $value){ if(!is_int($value)) array_push($string_keys, $value); } $row = $results[0]; foreach($string_keys as $value) $object->$value = $row[$value]; }
function FillDB($qry, $value="") { $rows = DataBase::ExecuteQuery($qry); foreach($rows as $key => $row) $this->AddItem ($row[0],$row[1]); }
<?php $sql = "SELECT idnews,title,fddate FROM news WHERE ambit=1 ORDER BY fddate DESC LIMIT 5"; $rs = DataBase::ExecuteQuery($sql, "ARRAY"); $i = count($rs); foreach ($rs as $row => $value) { $class = $row == '0' ? 'class="first"' : ''; echo '<li ' . $class . ' >'; echo '<a href="javascript:;" onclick="get(\'panel_control/viewer_news.php?id=' . $value['idnews'] . '\',\'content\');" >' . $value['title'] . '</a>'; echo '</li>'; } ?> </ul> </div> <div class="box"> <h3>Eventos</h3> <ul class="list"> <?php $sql = "SELECT idnews,title,fddate FROM news WHERE ambit=2 ORDER BY fddate DESC LIMIT 5"; $rs = DataBase::ExecuteQuery($sql, "ARRAY"); $i = count($rs); foreach ($rs as $row => $value) { $class = $row == '0' ? 'class="first"' : ''; echo '<li ' . $class . ' >'; echo '<a href="javascript:;" onclick="get(\'panel_control/viewer_news.php?id=' . $value['idnews'] . '\',\'content\');" >' . $value['title'] . '</a>'; echo '</li>'; } ?> </ul> </div> </div>