Autor Zpráva
Adrifinel
Profil *
  $prikaz =MySQL_Query("SELECT * FROM `kalendar` WHERE DAYOFYEAR(datum)=346");


Chtěla bych udělat, aby se mi z db vypisovaly zprávy podle toho jaký je den. Myslím tím, že když např. mám
27.8.1998 se stala tato událost, tak až bude v kalendáři datum 27.8 tak aby se zobrazilo: 27.8.1998 se stala tato událost.

Zkoušela jsem ten příkaz dát dohromady, ale moc mi to nejde.
Str4wberry
Profil
Co znamená „moc to nejde“?
Adrifinel
Profil *
No, že se mi to nevypisuje....jako nedaří se mi to dát dohromady.
Pak mě napadlo, jestli to není blbost a zkusila jsem tohle:

$spojeni = $connect;
	MySQL_Select_DB("$db");
	if($Date!=""):
  $vysledekrep1 = MySQL_Query("SELECT * FROM `kalendar` WHERE 'DAYOFYEAR(datum)'");
  $prichozi =  MySQL_Num_Rows($vysledekrep1) ;
    endif;


Vím, že budu potřebovat tři věci: 1) je zjištění dnešního data 2) zjištění kolikátý je to den v roce 3)vypsat to podle těch dvou podmínek.
YoSarin
Profil
Adrifinel:
2) zjištění kolikátý je to den v roce
To není dobrý nápad - mysli na přestupné roky.

Myslím že by mělo fungovat:
SELECT * FROM kalendar WHERE DAY(NOW()) = DAY(datum) AND MONTH(NOW()) = MONTH(datum);
Adrifinel
Profil *
YoSarin:

Tak jsem to zkusila, ale nic to nedělá. Tím myslím, že to neukaže ani čárku.
Str4wberry
Profil
No, že se mi to nevypisuje

Když tu kód zajišťující nějaký výpis vůbec není uveden, těžko můžeme poradit.
Adrifinel
Profil *
<?php
 	$spojeni = $connect;
	MySQL_Select_DB("$db");
  $prikaz =MySQL_Query("SELECT * FROM kalendar WHERE DAY(NOW()) = DAY(datum) AND MONTH(NOW()) = MONTH(datum)");
?>


Stačí to takhle, tohle jsem totiž zkoušela.
Str4wberry
Profil
Aha, pojďme si projít, co uvedený kód dělá.

1. Přiřadí do proměnné $spojeni proměnnou $connect.
2. Vybere databázi s názvem uloženým v proměnné $db.
3. Přiřadí do proměnné $prikaz výsledek SQL dotazu (ten je funkční).

A kde máme výpis, hm?
valecekm
Profil
Str4wberry:
Chápu, že slečna či paní samozřejmně neudělala výpis, a měla by si otom nejprve něco přečíst a pak to teprve řešit, ale to pání moderátoři snad neznamená, že budeme jak to říci?..zlomyslní a urýpaní?

Na jednu stranu chápu, že se Vám fórum plní zbytečnýma dotazama, ale od čeho tu potom to fórum je? Ano, nejdříve hledat, ale když už na dotaz odpovím, tak aspoň tak, abych dotyčného neponížil či ho nějak nepošpinil, neříkám že se to stalo, ale neuškodilo by trošku CTI k přítomným zde na fóru. Lepší by v tomto případě bylo, přehodit toto vlákno na jíne, kde se to již řešilo a nebo to rovnou napsat jak na to, poněvadž všichni nevidí do problematiky jako ti zkušenější.

Adrifinel:
Zkuste si něco nejdříve nastudovat www.builder.cz/art/php/php_select.html. Váš skript sice vydoluje data z databáze, ale k jejich výpisu potřebujete další část php skriptu a to nejlépe cyklus WHILE.
Str4wberry
Profil
Nejsem zlomyslný ani rýpavý. Ale dokud je formát zdejšího fóra diskusní (ne třeba formou otázek a odpovědí), tak vidím jako přínosnější tazatele k cíli popostrčit než mu přímo naservírovat hotové řešení, ačkoliv by to pro mě bylo rychlejší.
hunter_dave
Profil
Nejprve si v databázi vytvoř tabulku "kalendar" se sloupci "day", "month" a "text".

$time=time(); //zjistime počet sekund od 1.1.1970
$day=strftime("%d", $time);
$month=strftime("%m", $time); //zjistíme kolikátý den a v kolikátém měsíci je

$vysledek = mysql_query( "SELECT * FROM kalendar WHERE `day`='$day' and `month`='$month'");
//vybereme z databáze z tabulky "kalendar" řádky, které odpovídají tomuto dni a měsíci

while ($zaznam = mysql_fetch_array($vysledek) ):
$text = $zaznam["text"]; //z databáze vytáhneme text ke dni
echo $text; //vypíšeme z text
endwhile;
David84711
Profil *
Já jsem dělal něco podbného u sebe. A vyřešil jsem to tak, že jsem si stáhl kod na svátky, ať to nemusím psát ručně... (viz dole). A místo "a svátek má " napíšeš např. "s stala se tato událost:" A místo jména napíše co se stalo...

Je to ale drbačka a je to nadlouho....

<html>

<head>
<title>Svátky</title>
</head>
<body>

<SCRIPT>
var now = new Date();
var yr = now.getYear();
var mName = now.getMonth() + 1;
var dName = now.getDay() + 1.;
var dayNr = ((now.getDate()<10) ? "" : "")+ now.getDate();

if(dName==1) Day = "Neděle";
if(dName==2) Day = "Pondělí";
if(dName==3) Day = "Úterý";
if(dName==4) Day = "Středa";
if(dName==5) Day = "Čtvrtek";
if(dName==6) Day = "Pátek";
if(dName==7) Day = "Sobota";
if(mName==1) Month="1.";
if(mName==2) Month="2.";
if(mName==3) Month="3.";
if(mName==4) Month="4.";
if(mName==5) Month="5.";
if(mName==6) Month="6.";
if(mName==7) Month="7.";
if(mName==8) Month="8.";
if(mName==9) Month="9.";
if(mName==10) Month="10.";
if(mName==11) Month="11.";
if(mName==12) Month="12.";

// String to display current date.
var todaysDate =(" "
+ Day
+ " "
+ dayNr
+ ". "
+ Month
+ " "
+ yr);
// Write date to page.

document.open();
document.write("Dnes je <b> "+todaysDate+"</b> a svátek má <b>");

today = new Date();
den=today.getDate();
mesic=(today.getMonth()+1);
if (mesic==1) {
if (den==01) document.write("Nový rok");
if (den==02) document.write("Karina");
if (den==03) document.write("Radmila");
if (den==04) document.write("Diana");
if (den==05) document.write("Dalimil");
if (den==06) document.write("Tři králové");
if (den==07) document.write("Vilma");
if (den==08) document.write("Čestmír");
if (den==09) document.write("Vladan");
if (den==10) document.write("Břetislav");
if (den==11) document.write("Bohdana");
if (den==12) document.write("Pravoslav");
if (den==13) document.write("Edita");
if (den==14) document.write("Radovan");
if (den==15) document.write("Alice");
if (den==16) document.write("Ctirad");
if (den==17) document.write("Drahoslav");
if (den==18) document.write("Vladislav");
if (den==19) document.write("Doubravka");
if (den==20) document.write("Ilona");
if (den==21) document.write("Běla");
if (den==22) document.write("Slavomír");
if (den==23) document.write("Zdeněk");
if (den==24) document.write("Milena");
if (den==25) document.write("Miloš");
if (den==26) document.write("Zora");
if (den==27) document.write("Ingrid");
if (den==28) document.write("Otýlie");
if (den==29) document.write("Zdislava");
if (den==30) document.write("Robin");
if (den==31) document.write("Marika");
}
if (mesic==2) {
if (den==01) document.write("Hynek");
if (den==02) document.write("Nela");
if (den==03) document.write("Blažej");
if (den==04) document.write("Jarmila");
if (den==05) document.write("Dobromila");
if (den==06) document.write("Vanda");
if (den==07) document.write("Veronika");
if (den==08) document.write("Milada");
if (den==09) document.write("Apolena");
if (den==10) document.write("Mojmír");
if (den==11) document.write("Božena");
if (den==12) document.write("Slavěna");
if (den==13) document.write("Věnceslav");
if (den==14) document.write("Valentýn");
if (den==15) document.write("Jiřina");
if (den==16) document.write("Ljuba");
if (den==17) document.write("Miloslava");
if (den==18) document.write("Gizela");
if (den==19) document.write("Patrik");
if (den==20) document.write("Oldřich");
if (den==21) document.write("Lenka");
if (den==22) document.write("Petr");
if (den==23) document.write("Svatopluk");
if (den==24) document.write("Matěj");
if (den==25) document.write("Liliana");
if (den==26) document.write("Dorota");
if (den==27) document.write("Alexandr");
if (den==28) document.write("Lumír");
if (den==29) document.write(".....");
}
if (mesic==3) {
if (den==01) document.write("Bedřich");
if (den==02) document.write("Anežka");
if (den==03) document.write("Kamil");
if (den==04) document.write("Stela");
if (den==05) document.write("Kazimir");
if (den==06) document.write("Miroslav");
if (den==07) document.write("Tomáš");
if (den==08) document.write("Gabriela");
if (den==09) document.write("Františka");
if (den==10) document.write("Viktorie");
if (den==11) document.write("Anděla");
if (den==12) document.write("Řehoř");
if (den==13) document.write("Růžena");
if (den==14) document.write("Růt a Matylda");
if (den==15) document.write("Ida");
if (den==16) document.write("Elena a Herbert");
if (den==17) document.write("Vlastimil");
if (den==18) document.write("Eduard");
if (den==19) document.write("Josef");
if (den==20) document.write("Světlana");
if (den==21) document.write("Radek");
if (den==22) document.write("Leona");
if (den==23) document.write("Ivona");
if (den==24) document.write("Gabriel");
if (den==25) document.write("Marian");
if (den==26) document.write("Emanuel");
if (den==27) document.write("Dita");
if (den==28) document.write("Soňa");
if (den==29) document.write("Taťána");
if (den==30) document.write("Arnošt");
if (den==31) document.write("Kvido");
}
if (mesic==4) {
if (den==01) document.write("Hugo");
if (den==02) document.write("Erika");
if (den==03) document.write("Richard");
if (den==04) document.write("Ivana");
if (den==05) document.write("Miroslava");
if (den==06) document.write("Vendula");
if (den==07) document.write("Heřman a Hermína");
if (den==08) document.write("Ema");
if (den==09) document.write("Dušan");
if (den==10) document.write("Darja");
if (den==11) document.write("Izabela");
if (den==12) document.write("Julius");
if (den==13) document.write("Aleš");
if (den==14) document.write("Vincenc");
if (den==15) document.write("Anastázie");
if (den==16) document.write("Irena");
if (den==17) document.write("Rudolf");
if (den==18) document.write("Valérie");
if (den==19) document.write("Rostislav");
if (den==20) document.write("Marcela");
if (den==21) document.write("Alexandra");
if (den==22) document.write("Evženie");
if (den==23) document.write("Vojtěch");
if (den==24) document.write("Jiří");
if (den==25) document.write("Marek");
if (den==26) document.write("Oto");
if (den==27) document.write("Jaroslav");
if (den==28) document.write("Vlastislav");
if (den==29) document.write("Robert");
if (den==30) document.write("Blahoslav");
}
if (mesic==5) {
if (den==01) document.write(".....");
if (den==02) document.write("Zikmund");
if (den==03) document.write("Alexej");
if (den==04) document.write("Květoslav");
if (den==05) document.write("Klaudie");
if (den==06) document.write("Radoslav");
if (den==07) document.write("Stanislav");
if (den==08) document.write(".....");
if (den==09) document.write("Ctibor");
if (den==10) document.write("Blažena");
if (den==11) document.write("Svatava");
if (den==12) document.write("Pankrác");
if (den==13) document.write("Servác");
if (den==14) document.write("Bonifác");
if (den==15) document.write("Žofie");
if (den==16) document.write("Přemysl");
if (den==17) document.write("Aneta");
if (den==18) document.write("Nataša");
if (den==19) document.write("Ivo");
if (den==20) document.write("Zbyšek");
if (den==21) document.write("Monika");
if (den==22) document.write("Emil");
if (den==23) document.write("Vladimír");
if (den==24) document.write("Jana");
if (den==25) document.write("Viola");
if (den==26) document.write("Filip");
if (den==27) document.write("Valdemar");
if (den==28) document.write("Vilém");
if (den==29) document.write("Maxmilián");
if (den==30) document.write("Ferdinand");
if (den==31) document.write("Kamila");
}
if (mesic==6) {
if (den==01) document.write("Laura");
if (den==02) document.write("Jarmil");
if (den==03) document.write("Tamara");
if (den==04) document.write("Dalibor");
if (den==05) document.write("Dobroslav");
if (den==06) document.write("Norbert");
if (den==07) document.write("Iveta a Slavoj");
if (den==08) document.write("Medard");
if (den==09) document.write("Stanislava");
if (den==10) document.write("Gita");
if (den==11) document.write("Bruno");
if (den==12) document.write("Antonie");
if (den==13) document.write("Antonín");
if (den==14) document.write("Roland");
if (
hunter_dave
Profil
Javascript se na tohle moc nehodí. Je opravdu lepší mít nějakou databázi a volat data podle pomocí php. A krom toho javascript určuje čas podle klienta .. to znamená pokud klient nemá nastavený čas, nebo ho má nastavený špatně zobrazí se mu něco jiného. php bere čas ze serveru :)

Vaše odpověď


Prosím používejte diakritiku a interpunkci.

Ochrana proti spamu. Napište prosím číslo dvě-sta čtyřicet-sedm:

0