Msaada hii function php mysql

Brodre

JF-Expert Member
Aug 23, 2012
2,330
2,000
Wakuu natak kuquery data from database,

ila nataka kuzigroup kwa miezi, Yaani mfano nina attendance ya kuanzia mwezi wa kwanza ila nataka nivute data zote zinipe link ya miezi kimfano ni kiclick mwezi wa kwanza iniletee data za mwezei wa kwanza pekee hivyo hivyo mwezi wa pili. Ila itoe hizo month links according to dates ambazo ziko kwenye database tu.

CC C6 Nyasiro Stefano Mtangoo na wengine
 
Last edited by a moderator:

Nyasiro

JF-Expert Member
Feb 20, 2012
1,197
2,000
Bado cjaelewa tatizo lipo kwenye kukupa link au ku-query database. Kama tatizo ni kukupa link mimi sielewi hiyo PHP yako inaendaje lakini kama tatizo ni kuvuta data kutoka kwenye database unaweza tumia SQL SELECT + WHERE na kupata data zako.

Ok kwa ufupi unaweza fanya hivi

kwanza inabidi u-query database ili upate tarehe au miez yako

Mfano
Code:
SELECT * FROM date

Hapo utagenerate tarehe zako ambazo zitatokea kwenye form ambayo utazitumia mtu anapoklick kama link (inabidi utumie PHP ili result iwe katika link ambayo utaitumia badae)

Ukishamaliza sasa unakuwa una-query kulingana na link (tarehe) iliyokuwa clicked yaani baada ya SELECT utaweka WHERE itakayofuatiwa na tatehe iliyokuwa clicked.
 

deejaywillzz

JF-Expert Member
Mar 11, 2014
637
195
Unahabari hii ni full project unaongelea sababu inaonekana hujafanya effort ya kianzio ili tukuongezee. Siku nyingine post na code yako ili watu wajue jinsi gani ya kusaidi.

Nakupa hinti ndogo nyingine utatafuta mwenyewe.

PHP:
//OPEN THE CONNECTION

requestedMonth = 2; // badala ya kuweka mbili unaweza ku query value kutoka kwenye URL

$result = mysql_query("SELECT * FROM attendance WHERE DATE_FORMAT(attendance_date, '%m') = requestedMonth");

while($row = mysql_fetch_array($result)){
  echo "Attendee: " .$row['full_name']. "<hr>";
}

//CLOSE THE CONNECTION
 

xfactor

JF-Expert Member
Jan 25, 2014
1,511
1,250
Hii ni njia ndefu ila rahisi. Inatumia query mbili lakini unaweza Kutumia query moja but inabidi nijue database yako ume design vipi

Table name : Attendance
Fields: date and attendanceID(primary key)


$query= mysql _query("select distinct date from Attendance")

While(result=mysql_fetch_assoc($query))
{
echo "<a href='report.php?Date=".$result['date']."'>".$result['date']."<\a>";
}

Kwenye page yako ya report GET parameter date from url

$query2=mysql_query("select * from Attendance where date ='".$_GET['date']."'");

While($result2=mysql_fetch_assoc($query2))
{
echo "<a href='report.php?id=".$result2['attendanceID']."'>".$result2['date']."<\a>";
}
 

xfactor

JF-Expert Member
Jan 25, 2014
1,511
1,250
Sorry kwenye hiyo while loop ya pili display information zote na si link tena.

Kimsingi Unatakiwa uwe na page ambayo Itakuwa na listi za tarehe zote(unaweza kuchukua miezi tu kutoka kwenye tarehe kwa kutumia date function). Then kila tarehe itakuwa kama link as shown kwenye while loop ya kwanza

Then mtu aki click link itamletea results zote za tarehe husika
 

Brodre

JF-Expert Member
Aug 23, 2012
2,330
2,000
Kang Nyasiro xfactor deejaywillzz Stefano Mtangoo Chief Lugina Smahani nimechelewa kuleta feedback. Asanteni kwa mawazo yenu kwa manufaa ya weengine nilifanya steps zifuatazo,
1. nilianaza kwa kuquery calender iliyokuwa kwenye database
PHP:
$getmonth=$icon->query("select * from attendance where uid = '".$stuid."' group by EXTRACT(MONTH from adate) order by adate desc");
Nilitumia group by extract (month) ili i group kwa miez

2. Baada ya hapo nikaquery data kutokwa kwenye database kwa kutumia links za miezi ambazo nimetengeneza hapo juu
PHP:
$sql2=$icon->query("select * from attendance where uid = '".$stuid."' and adate like '".$cudate."%'  order by adate Desc limit 31");
 
Last edited by a moderator:

Toa taarifa ya maudhui yasiyofaa!

Kuna taarifa umeiona humu JamiiForums na haifai kubaki mtandaoni?
Fanya hivi...

Umesahau Password au akaunti yako?

Unapata ugumu kuikumbuka akaunti yako? Unakwama kuanzisha akaunti?
Contact us

Top Bottom