'$cas_akt_str' LIMIT 1"; $result = mysql_query($sql) or die (mysql_error()); if(mysql_num_rows($result)) $r = mysql_fetch_array($result); else { $sql = "SELECT model_id FROM sms_vip ORDER BY do DESC LIMIT 1"; $result = mysql_query($sql) or die (mysql_error()); $r = mysql_fetch_array($result); } $VIP_MODEL = $r["model_id"]; $sql="SELECT tabKlic.id, model.nick, model.logo FROM ( SELECT model.id AS id FROM model UNION SELECT podnik.id FROM podnik ) AS tabKlic LEFT JOIN model ON tabKlic.id = model.id LEFT JOIN podnik ON model.podnik_id = podnik.id WHERE model.id = $VIP_MODEL LIMIT 1;"; $result = mysql_query($sql) or die(mysql_error()); $r = mysql_fetch_array($result); $sql="UPDATE model SET counter = counter+1 WHERE id = $VIP_MODEL LIMIT 1"; mysql_query($sql) or die(mysql_error()); ?>