contact

Posts Tagged ‘php’

php and mysql full text search across multiple tables using a relevancy score

Wednesday, June 24th, 2009

the setup

I am currently building a paltfrom to host my air applications on. this is plattform includes a feedback and bug tracking forum application where users can post their thoughts and problems. In order for this to be helpfull i needed to implement full text search. the forum constists of basically two tables.

  • 1.) threads (title,date,author_id,forum_id,threadComment_id)
  • 2.) comments (text, author, date,thread_id)

so the way this works is that a user can open up a thread , which stores a new thread and a comment in the database. the two are linked by adding the thread Id to the comment and the comments unique id to the thread. any futur comments that are posted to this thread will simply have the thread Id stored in them.

calculating the number of days between two dates

Sunday, November 9th, 2008

for a recent project I had to figure out how many days are between a given start and end date. My first very poor attempt was to split the dates and then get the monthes and then add up the days for each month. Very poor on performance.

The easy solution:

most modern programming languages offer Dates Objects that can handle timestamps, which makes our calculation very easy.

(Timestamp(endDate)-TimeStamp(startDate)) / 3600 / 24 = days

this will compute the amount of seconds between the start and end date, then divide by 3600 gives you get hours, divide by 24 and you have the number of days. This is especially nice since it automatically considers 29th of february.

note: if you use actionscript you have to again divide by 1000 since its timestamps are in milli seconds.

actionscript 3 screenshot

actionscript 3 screenshot

Using Anchors and GET variables

Monday, February 18th, 2008

Well in general it is impossible to use them both. So http://www.yourdomain.com/yourpage.php?get=fubar#anchor1 is not going to work in most browsers, so we want to forget about that. I solved this problem with a little javascript workaround and an additional GET varibale. So step one is that your links would have to include a get variable “?a=YourAnchor”. Now we dont use the usual anchor but place a div with the id YourAnchor at the position we want the page to jump to. I use some javascript that is called when the page loads and the looks up the div with the id YourAnchor and scrolls the page to its position.

</pre>
<div id="YourAnchor"></div>
onload="go_to('<?php echo $_GET['a']; ?>')"

//in order to call the function simply place the following code in your body tag
<pre>

note that this is quite insecure though.

Using Mysql Data in Flash via php

Sunday, January 20th, 2008

In this post I want to describe a very simple technique I use in order to read Mysql data into flash via a php-dynamically created xml file. So what do you need to get this work:

  • a Mysql Database filled with Data of your choice
  • a php capable webserver, if you dont want to upload everytime for testing try installing

www.akutron.com

Tuesday, January 8th, 2008

I created this website during my internship in kiew for the technology company Akutron. its nothing really special, just some basic html css and a little php for the different languages, although the translations never got done. www.akutron.com

Flash – php – MySql Filesystem

Monday, January 7th, 2008

I am working on a browser based flash UI