View Full Version : Ramadhan Timetable script help
Salams
does anyone here know or have a script that you can display prayer times on a website according to the date
basically i have a XL spreadsheet with Salat times for Ramadhan
Basicalyl What i want tto do is on the website display
Iftaari Time
Suhoor Time
What i want it to do is to pick up the times from the Database (which is the excel spreadsheet) and according to the day date display it on the webpage
any one have any ideass how i wud go on about doing this please?
ws
sajid
ammarcool
02-09-07, 05:51 PM
brother what is the backend & the script that you are planning to use?
brother i can do it on ASP.NET by just writing a SQL Query to pick those 2 ifthaar & suhoor times once we passed that particular date to that QUERY.
EX:
SELECT TABLE1.SUHOORTIME, TABLE1.IFTHAARTIME
FROM TABLE1
WHERE TABLE1.TODAYDATE='02-09-07' OR getDATE
LostInThought
02-09-07, 06:03 PM
If it's an excel 2007 file you can connect to it via:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0;HDR=YES";
If it's an earlier version of excel then:
Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=C:\MyExcel.xls;DefaultDi r=c:\mypath;
or
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";
once connected you can do your standard sql queries like this:
SELECT * FROM [sheet1$]
if you have 3 columns called
date, Iftaari, and Suhoor.
you could do a query something like this:
select iftaari, suhoor from [sheet1$] where date = getdate()
i think.
then you probably know the rest of the php.
brother what is the backend & the script that you are planning to use?
brother i can do it on ASP.NET by just writing a SQL Query to pick those 2 ifthaar & suhoor times once we passed that particular date to that QUERY.
EX:
SELECT TABLE1.SUHOORTIME, TABLE1.IFTHAARTIME
FROM TABLE1
WHERE TABLE1.TODAYDATE='02-09-07' OR getDATE
salams
php mysql i plan to use!
would you know the code for that please? :) or the query
If it's an excel 2007 file you can connect to it via:
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0;HDR=YES";If it's an earlier version of excel then:
Driver={Microsoft Excel Driver (*.xls)};DriverId=790;Dbq=C:\MyExcel.xls;DefaultDi r=c:\mypath;or
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\MyExcel.xls;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1";once connected you can do your standard sql queries like this:
SELECT * FROM [sheet1$]if you have 3 columns called
date, Iftaari, and Suhoor.
you could do a query something like this:
select iftaari, suhoor from [sheet1$] where date = getdate()i think.
then you probably know the rest of the php.
hmm thats using windows ASP stuff?
the server is runnign linux has php mysql installed so will prolly be using that
LostInThought
02-09-07, 08:44 PM
hmm thats using windows ASP stuff?
the server is runnign linux has php mysql installed so will prolly be using that
Nope, no asp in that script. it was just sql and a connectionstring, which should be compatible with all web serverside languages.
ammarcool
03-09-07, 08:56 AM
brother just refer this code:
<?php
$data = array();
function add_person( $first, $middle, $last, $email )
{
global $data;
$data []= array(
'first' => $first,
'middle' => $middle,
'last' => $last,
'email' => $email
);
}
if ( $_FILES['file']['tmp_name'] )
{
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
$rows = $dom->getElementsByTagName( 'Row' );
$first_row = true;
foreach ($rows as $row)
{
if ( !$first_row )
{
$first = "";
$middle = "";
$last = "";
$email = "";
$index = 1;
$cells = $row->getElementsByTagName( 'Cell' );
foreach( $cells as $cell )
{
$ind = $cell->getAttribute( 'Index' );
if ( $ind != null ) $index = $ind;
if ( $index == 1 ) $first = $cell->nodeValue;
if ( $index == 2 ) $middle = $cell->nodeValue;
if ( $index == 3 ) $last = $cell->nodeValue;
if ( $index == 4 ) $email = $cell->nodeValue;
$index += 1;
}
add_person( $first, $middle, $last, $email );
}
$first_row = false;
}
}
?>
<html>
<body>
<table>
<tr>
<th>First</th>
<th>Middle</th>
<th>Last</th>
<th>Email</th>
</tr>
<?php foreach( $data as $row ) { ?>
<tr>
<td><?php echo( $row['first'] ); ?></td>
<td><?php echo( $row['middle'] ); ?></td>
<td><?php echo( $row['last'] ); ?></td>
<td><?php echo( $row['email'] ); ?></td>
</tr>
<?php } ?>
</table>
</body>
</html>
the code sample retrieves first, middle, last, email from the excel sheet, instead of it you have to extract suhoor & ifthaar time from your excel sheet! hope inshalalh you got some idea. :)
just refer this link for your reference: http://www-128.ibm.com/developerworks/opensource/library/os-phpexcel/
ammarcool
03-09-07, 09:25 AM
i dont have installed php installed in my laptop. just try it brother! if anything just shoot it here. :)
just refer that above URL & follow it brother!
ammarcool
03-09-07, 10:07 AM
came across another sample, just try it:
1. You must have the Excel ODBC driver in your ODBC32 Control
Panel Entry. Don't ask me how and when it gets installed: I
just used the one I found in a pretty stock installation :)
2. Configuration of the ODBC driver: add a DSN choosing the
Excel driver and give it a name (i.e. "excelsux" :)).
Point it to an existing worksheet.
3. In the worksheet select a range of cells then Insert->Name->Define
(YMMV, my Excel is in Italian) and give a name to the
selection (i.e. "myselection").
4. PHP code finally: :)
/* Didn't try to protect it via user/pwd */
if (($id = odbc_pconnect("excelsux"))) {
if (($r = odbc_exec($id, "SELECT * FROM myselection"))) {
odbc_result_all($r); // Or whatever you want
}
}
http://www.weberdev.com/get_example-1270.html
following code show us the way to RETRIEVE data from an EXCEL sheet. just go through it! similar way you have to do it in php.
Sub GetWorksheetData(strSourceFile As String, strSQL As String, TargetCell As Range)
Dim cn As ADODB.Connection, rs As ADODB.Recordset, f As Integer, r As Long
If TargetCell Is Nothing Then Exit Sub
Set cn = New ADODB.Connection
On Error Resume Next
cn.Open "DRIVER={Microsoft Excel Driver (*.xls)};DriverId=790;" & _
"ReadOnly=True;DBQ=" & strSourceFile & ";"
' DriverId=790: Excel 97/2000
' DriverId=22: Excel 5/95
' DriverId=278: Excel 4
' DriverId=534: Excel 3
On Error GoTo 0
If cn Is Nothing Then
MsgBox "Can't find the file!", vbExclamation, ThisWorkbook.Name
Exit Sub
End If
' open a recordset
Set rs = New ADODB.Recordset
On Error Resume Next
rs.Open strSQL, cn, adOpenForwardOnly, adLockReadOnly, adCmdText
' rs.Open "SELECT * FROM [SheetName$]", _
cn, adOpenForwardOnly, adLockReadOnly, adCmdText
' rs.Open "SELECT * FROM [SheetName$]", _
cn, adOpenStatic, adLockOptimistic, adCmdText
' rs.Open "SELECT * FROM [SheetName$] WHERE [Field Name] LIKE 'A%'", _
cn, adOpenStatic, adLockOptimistic, adCmdText
' rs.Open "SELECT * FROM [SheetName$] WHERE [Field Name] LIKE 'A%' " & _
"ORDER BY [Field Name]", cn, adOpenStatic, adLockOptimistic, adCmdText
' optional ways of retrieving a recordset
' Set rs = cn.Execute("[A1:Z1000]") ' first worksheet
' Set rs = cn.Execute("[DefinedRangeName]") ' any worksheet
On Error GoTo 0
If rs Is Nothing Then
MsgBox "Can't open the file!", vbExclamation, ThisWorkbook.Name
cn.Close
Set cn = Nothing
Exit Sub
End If
RS2WS rs, TargetCell
' TargetCell.CopyFromRecordset rs ' use with Excel 2000 or later
If rs.State = adStateOpen Then
rs.Close
End If
Set rs = Nothing
cn.Close
Set cn = Nothing
End Sub
why duncha just make a table in sql with the feilds date, iftar, sahoor
and then in yer php write a query that displays the iftar n sahoor where the days date matches datein the date field:rubeyes:
LostInThought
03-09-07, 02:40 PM
why duncha just make a table in sql with the feilds date, iftar, sahoor
and then in yer php write a query that displays the iftar n sahoor where the days date matches datein the date field:rubeyes:
I thought the same thing, but then thought, maybe there is a reason why he don't want to do that?
I thought the same thing, but then thought, maybe there is a reason why he don't want to do that?
maybe he likes to make life complicated :p
Suliman
03-09-07, 02:45 PM
MMS, you're a bit nerdy for a sister aren't you?
You'll make some lucky WoW brother a happy husband one day :P
LostInThought
03-09-07, 02:49 PM
maybe he likes to make life complicated :p
yes, we can't rule that possibility out just yet.
LostInThought
03-09-07, 02:50 PM
MMS, you're a bit nerdy for a sister aren't you?
You'll make some lucky WoW brother a happy husband one day :P
she knows more about nerdy stuff than most brothers here. :nerdsis:
Suliman
03-09-07, 02:57 PM
she knows more about nerdy stuff than most brothers here. :nerdsis:
tut tut no that's just sexist, next you will be telling she wears a parker coat, rides a chopper and watches X-Files whilst wearing her 'big up' NHS glasses, shame on you! Now behave :P
Seriously though MMS do you do any coding work?
tut tut no that's just sexist, next you will be telling she wears a parker coat, rides a chopper and watches X-Files whilst wearing her 'big up' NHS glasses, shame on you! Now behave :P
Seriously though MMS do you do any coding work?
x-files was pretty cool :rubeyes:
i dont have glasses lol im staying out of this section now :p
im not sure if i should answer the last question :outta:
Suliman
03-09-07, 03:08 PM
x-files was pretty cool :rubeyes:
i dont have glasses lol im staying out of this section now :p
im not sure if i should answer the last question :outta:
The last question was serious in regards to work. I throw coding work about to various people, I'd rather it was a muslim.
If you have work to show or want to go about this more, let me know.
why duncha just make a table in sql with the feilds date, iftar, sahoor
and then in yer php write a query that displays the iftar n sahoor where the days date matches datein the date field:rubeyes:
yah i can do that no problem
its just the query im after..if anyone knows is
so something like
whatever is the date today look at the database then find that field and pull out the iftaar and suhoor filed and display it
anyone know what it wud be?
LostInThought
03-09-07, 04:58 PM
yah i can do that no problem
its just the query im after..if anyone knows is
so something like
whatever is the date today look at the database then find that field and pull out the iftaar and suhoor filed and display it
anyone know what it wud be?
select iftaar, suhoor from yourtable where convert(varchar,the_date,23) = convert(varchar,getdate(),23)
x-files was pretty cool :rubeyes:
i dont have glasses lol im staying out of this section now :p
im not sure if i should answer the last question :outta:
what were you wearing a little while ago downstairs? :outta:
Suliman
03-09-07, 08:32 PM
what were you wearing a little while ago downstairs? :outta:
lol now now girls calm down calm down. I feel guilty now.
Anyway, you good for paid work or not, you defiantly show promise (sorry but I have to be blunt in business :P)
yah i can do that no problem
its just the query im after..if anyone knows is
so something like
whatever is the date today look at the database then find that field and pull out the iftaar and suhoor filed and display it
anyone know what it wud be?
assuming you use the field type date in ur date field in SQL
you would need to set your date variable in php to something like this
var $today = date(Y-m-d);and then ur query will look something like this
$query = mysql_query("SELECT iftar FROM ramadhan WHERE date='$today'")then print yer iftaar date n do the same for sahoor
what were you wearing a little while ago downstairs? :outta:
they wernt mine :torture:
lol now now girls calm down calm down. I feel guilty now.
Anyway, you good for paid work or not, you defiantly show promise (sorry but I have to be blunt in business :P)
ill get back to ya on that, in the middle of something atm
assuming you use the field type date in ur date field in SQL
you would need to set your date variable in php to something like this
var $today = date(Y-m-d);and then ur query will look something like this
$query = mysql_query("SELECT iftar FROM ramadhan WHERE date='$today'")then print yer iftaar date n do the same for sahoor
they wernt mine :torture:
ill get back to ya on that, in the middle of something atm
lool oki did u fix the probb i need to print :o
Suliman
03-09-07, 09:24 PM
ill get back to ya on that, in the middle of something atm
Groovy!
LostInThought
04-09-07, 11:21 AM
Sajid
I had a few moments so I thought I'd give this a go. I don't have a php server or a database with the relievant data so it might not work. Also, I'm a php noob so most likely it is not optimised. I opted to use the "getDate()" function at the sql script level to check which date it is today.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-Strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
</head>
<body>
<div>
<?php
function getRamadanTimes()
{
$connection = mysql_connect('servername', 'username', 'password') or die (mysql_error());
$db = mysql_select_db('databasename', $connection) or die (mysql_error());
$query = "select date_column, iftaar, sahoor from your_table where convert(varchar,the_date,23) = convert(varchar,getdate(),23)";
$result = mysql_query($query) or die (mysql_error());
$row = mysql_fetch_array($result);
extract($row);
return "<span>Date: ".$date_column." - Iftaar: ".$iftaar." - Sahoor: ".$sahoor."</span>";
}
echo getRamadanTimes();
?>
</div>
</body>
</html>
the sql query is compatible with ms sql server 2000, i have no idea if it will work in mysql.
let me know if it does, as i am interested in learning php/mysql syntax.
Sajid
I had a few moments so I thought I'd give this a go. I don't have a php server or a database with the relievant data so it might not work. Also, I'm a php noob so most likely it is not optimised. I opted to use the "getDate()" function at the sql script level to check which date it is today.
the sql query is compatible with ms sql server 2000, i have no idea if it will work in mysql.
let me know if it does, as i am interested in learning php/mysql syntax.
gives the error
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'varchar,the_date,23) = convert(varchar,getdate(),23)' at line 1this seems to work tho
<?php
function getRamadanTimes()
{
$today = date('Y-m-d');
$connection = mysql_connect('localhost', 'username', 'password') or die (mysql_error());
$db = mysql_select_db('databasename', $connection) or die (mysql_error());
$result = mysql_query("SELECT date, iftar, sahoor FROM table_name WHERE date='$today'")
or die(mysql_error());
$row = mysql_fetch_array($result);
extract($row);
return "<span>Date: ".$date." - Iftar: ".$iftar." - Sahoor: ".$sahoor."</span>";
}
echo getRamadanTimes();
?>it returns
Date: 2007-09-04 - Iftar: 18:55 :00 - Sahoor: 04:10:00from my database which looks like this
http://img166.imageshack.us/img166/6724/tableex5.gif
LostInThought
04-09-07, 01:26 PM
i had a feeling that sql query wouldn't work because of the convert section. does mysql have a cast/convert?
only reason why i use that is because the datetime datatype in sql server 2000 also inserts the time, so i was stripping off the time and giving the date the format Y-m-d.
i had a feeling that sql query wouldn't work because of the convert section. does mysql have a cast/convert?
only reason why i use that is because the datetime datatime in sql server 2000 also inserts the time, so i was stripping off the time and giving the date the format Y-m-d.
in mysql you can set a field type as just date which gives the format YYYY-MM-DD
and PHP has a date function http://uk2.php.net/date
i set the variable $today with the same format of date in the sql table
LostInThought
04-09-07, 03:12 PM
asp.net also has a date function but is a little longer winded...
datetime mydate = datetime.now.tostring("Y-m-d");
which is why i prefer to use sql's getDate() function.
i've become accustomed to coding with oop techniques like encapsulation, objects, methods, inheritance and so on when making websites with asp.net.
can i do that with php?
salams
thanks all i got a bro from MPADC.com to sort it out..it gets the data from a csv file here is the code
<?php
$ret = array();
$handle = fopen("iftar.csv", "r");
$date = date('j-M');
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
if ($data[1] == $date) {
//Get the times
$iftarScript[0] = $data[3];
$iftarScript[1] = $data[4];
break;
}
}
fclose($handle);
//Print suhoor and iftar times
if (!empty($iftarScript[0]))
print "Suhoor: {$iftarScript[0]}\nIftar: {$iftarScript[1]}\n";
else
print "No times found";
vBulletin® v3.7.2, Copyright ©2000-2008, Jelsoft Enterprises Ltd.