outsider_child Posted April 27, 2011 Share Posted April 27, 2011 I got this Event Calendar Script off of a site and i like it but it reads from a Flat File Database and i would like it to read from a mysql database. Can someone help me set it up so it will read from a mysql database? here is the script where its calling from the flat file.. $counterfilepath="calendar.txt"; if(file_exists($counterfilepath)) { $filehandle=fopen($counterfilepath,"r"); $pointer = 1; while(!feof($filehandle)) { $rowdata = fgets($filehandle); $day = floatval(substr($rowdata,3,2)); $eventlastpos = strpos($rowdata,'{')-1; if($eventlastpos<=0){$eventlastpos=255;} $event = rtrim(substr($rowdata,11,$eventlastpos-10)); $eventcaption = rtrim(substr($rowdata,$eventlastpos+2,strlen($rowdata))); $datalist = $this->eventsthismonth[$day]; $rowmonth = floatval(substr($rowdata,0,2)); $rowyear = floatval(substr($rowdata,6,4)); if($rowmonth==$month and $rowyear==$year) { if($eventcaption=="") {$eventcaption='';} else {$eventcaption='<b>'.$eventcaption.'</b><br>';} if($datalist=="") { $this->eventsthismonth[$day] = '<font name=Verdana size=1>'.$eventcaption.$event.'</font>'; } else { $this->eventsthismonth[$day] = $datalist.'<br><hr size=1 color=#E0E0E0><font name=Verdana size=1>'.$eventcaption.$event.'</font>'; } } $pointer = $pointer + 1; } fclose($filehandle); } and the flat file looks like this 07/13/2005|Technology Advisory Meeting{2:00pm Quote Link to comment https://forums.phpfreaks.com/topic/234891-event-calendar/ Share on other sites More sharing options...
gizmola Posted April 27, 2011 Share Posted April 27, 2011 This is not a forum for bringing in 3rd party scripts you don't understand and asking people to do free modifications for you. It's a place for people to learn PHP. Quote Link to comment https://forums.phpfreaks.com/topic/234891-event-calendar/#findComment-1207098 Share on other sites More sharing options...
outsider_child Posted April 27, 2011 Author Share Posted April 27, 2011 i understand them its just i never converted flat file databases to mysql database and i am asking for help not for someone to write the script. i can do the sql part its just not sure which parts i need to take out and stuff. here is what im not really figuring out.. $day = floatval(substr($rowdata,3,2)); what is 3,2 for? Quote Link to comment https://forums.phpfreaks.com/topic/234891-event-calendar/#findComment-1207110 Share on other sites More sharing options...
gizmola Posted April 27, 2011 Share Posted April 27, 2011 substr Returns the portion of string specified by the start and length parameters. Quote Link to comment https://forums.phpfreaks.com/topic/234891-event-calendar/#findComment-1207114 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.