HTML helping

Discuss, argue, whine, talk but not about Elma.

Moderator: Moporators

User avatar
Kopaka
39mins club
Posts: 6611
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: HTML helping

Post by Kopaka »

I'm pretty sure you have to use javascript ( not java (: ), some google search should find scripts to do it
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Re: HTML helping

Post by niN »

I see! BoneLESS helped me a little and I found some interesting links to try out.

http://www.tutorialspoint.com/script.ac ... ffects.htm the morph thing seems interesting. and it's javascript

Before I do that though, I can say that what I want is the same thing that exist on skintatious when a new record is broken on the main page the first position glow up and then slowly fade (check it out and you'll get a clear picture of what I want!)

But I'll go check that url bone gave me now!

EDIT I checked the url bone gave me out but it didn't give me what I wanted. first off, the borders wont be touched with it, and second you need to click it for the effect to start. I've been thinking more about using an animated background image though, this would be very easy to do (just do a tiny picture fading from one colour to another and then use the repeat option to get it to spread over the entire area), the problem is that I don't want it to play continuously, only once. Can I do this somehow?
Team HotHorses, and I'm converting to Icelandian now...
User avatar
Kopaka
39mins club
Posts: 6611
Joined: 23 May 2002, 13:59
Team: LAME
Location: In a northern danish city beating YOUR record.
Contact:

Re: HTML helping

Post by Kopaka »

I think when you make a gif file you can set it to only repeat once
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Re: HTML helping

Post by niN »

ah okay, so apparently you can choose this with the program you're making the image with. I'll try finding a good prog and see what happens!
Team HotHorses, and I'm converting to Icelandian now...
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Re: HTML helping

Post by niN »

arghufostr I've been trying to figure out how to motherfucking sort a fucking thing I have all goddamn day! And I can't do it nomatter what because I am trying to learn how to work with .txt files as databases and I am not used to it. AAAAAAAAAAAAAA pls help me. I have this code which works perfectly fine. The only problem is that it does not sort the lines. I want them to sort by date ($slots[0]). HOW can I do it pls?

Code: Select all

 $filename = "data/comments.txt";

 $striing = file_get_contents($filename);
 $lines = explode("\r\n",$striing);

 foreach ($lines as $line) {
  $slots = explode("×",$line);

  echo $slots[1] . ", " . strip_tags(stripslashes($slots[2]), '<b><i><u>') . "</br>";
 }
Team HotHorses, and I'm converting to Icelandian now...
User avatar
ville_j
Kuski
Posts: 1506
Joined: 17 Aug 2002, 15:45
Team: IS
Location: on the roof
Contact:

Re: HTML helping

Post by ville_j »

I think you could try sort($lines) or asort($lines) before entering the loop. Also, easier way to read a file into an array line by line is file($filename).
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Re: HTML helping

Post by niN »

didn't work. I think it's because the $lines look like this:
(date*nick*text*)(date*nick*text*)(date*nick*text*)(date*nick*text*)
Team HotHorses, and I'm converting to Icelandian now...
User avatar
The_BoneLESS
38mins club
Posts: 4604
Joined: 7 Sep 2003, 00:30
Team: HHIT
Location: Dangerously close to the St-Lawrence River
Contact:

Re: HTML helping

Post by The_BoneLESS »

niN wrote:arghufostr I've been trying to figure out how to motherfucking sort a fucking thing I have all goddamn day! And I can't do it nomatter what because I am trying to learn how to work with .txt files as databases and I am not used to it. AAAAAAAAAAAAAA pls help me. I have this code which works perfectly fine. The only problem is that it does not sort the lines. I want them to sort by date ($slots[0]). HOW can I do it pls?

Code: Select all

 $filename = "data/comments.txt";

 $striing = file_get_contents($filename);
 $lines = explode("\r\n",$striing);

 foreach ($lines as $line) {
  $slots = explode("×",$line);

  echo $slots[1] . ", " . strip_tags(stripslashes($slots[2]), '<b><i><u>') . "</br>";
 }
Well, it is always easier to sort some 2D array than a bunch of lines (given you want to sort only one part of the line (the date)).

You could do something like this:

Code: Select all

 $filename = "data/comments.txt";

 $striing = file_get_contents($filename);
 $lines = explode("\r\n",$striing);

 $arrToSort = array();

 foreach ($lines as $line) {
  $slots = explode("×",$line);
  
  array_push($arrToSort,$slots);
 }

$arrSorted = msort($arrToSort, "0", false); //Not sure if the 0 should be wrapped in double-quotes or with nothing.

foreach($arrSorted as $arrLine){
 echo $arrLine[1] . ", " . strip_tags(stripslashes($arrLine[2]), '<b><i><u>') . "</br>";
}
That last function i used is defined here:

Code: Select all

<?php
/**
 * 2D array sort based on a key
 *
 * @author $Author: <jasons at work dot com>
 *
 * @param array $array  Array to be sorted
 * @param string $id  The array key on which the array will be sorted
 * @param bool $sort_ascending  The order (ascending or descending)
 *                
 */
function msort($array, $id="hits", $sort_ascending=false) {
        $temp_array = array();
        while(count($array)>0) {
            $lowest_id = 0;
            $index=0;
            foreach ($array as $item) {
                if (isset($item[$id])) {
                                    if ($array[$lowest_id][$id]) {
                    if (strtolower($item[$id]) < strtolower($array[$lowest_id][$id])) {
                        $lowest_id = $index;
                    }
                    }
                                }
                $index++;
            }
            $temp_array[] = $array[$lowest_id];
            $array = array_merge(array_slice($array, 0,$lowest_id), array_slice($array, $lowest_id+1));
        }
		if ($sort_ascending) {
			return $temp_array;
		} else {
			return array_reverse($temp_array);
		}
    }
?>
Typed that quite fast, hopefully no mistakes in there...

EDIT: If it doesn't work, could you paste some lines of your text file so we can see what you are dealing with? (if you wish, fictionnal data for privacy)
Last edited by The_BoneLESS on 4 Feb 2010, 21:36, edited 2 times in total.
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
User avatar
The_BoneLESS
38mins club
Posts: 4604
Joined: 7 Sep 2003, 00:30
Team: HHIT
Location: Dangerously close to the St-Lawrence River
Contact:

Re: HTML helping

Post by The_BoneLESS »

This could be more readable (numeral indexes like 0 aren't as conveniant and understandable as representative indexes such as date)

Code: Select all

$filename = "data/comments.txt";

$striing = file_get_contents($filename);
$lines = explode("\r\n",$striing);

$arrToSort = array();

foreach ($lines as $line) {
  $arrLine = array();
  $slots = explode("×",$line);

  $arrLine['date'] = $slots[0];
  $arrLine['nick'] = $slots[1];
  $arrLine['text'] = $slots[2];
 
  array_push($arrToSort,$arrLine);
}

$arrSorted = msort($arrToSort, "date", false);

foreach($arrSorted as $arrLine){
echo $arrLine[1] . ", " . strip_tags(stripslashes($arrLine[2]), '<b><i><u>') . "</br>";
}
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Re: HTML helping

Post by niN »

Thank you boneless, I will test everything as soon as I've finished watching a film. I'll edit my post then (maybe two hours).

EDIT: argh, it still doesn't work :( I basically copied your code and it doesn't work. The outcome is: nothing is written. what does the: $array_to_sort = array(); does? should I write something in the array();?

EDIT #2: oh, didn't know I needed to post the function in the document aswell! it works now! I have a few questions though because I don't really know what I did there and for me to learn something I would like to know what I did.
1) What's with the array();? (used here: $array_to_sort = array();) did some research. I finally learnt wth an array is! been wondering for years but been too shy to ask. but why is the array(); empty?
2) array_push($array_to_sort, $slots); - what did I do just then? I will google the array_push() function but if you could explain aswell I would be happei :)
3) What's with the 'False' in this code: $array_sorted = msort($array_to_sort, 0, false);. I guess this is the actual sorting part where it sorts the $array_to_sort by $array_to_sort[0] (dates)

Thank you BoneLESS!
Team HotHorses, and I'm converting to Icelandian now...
Post Reply