HTML helping

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

Moderator: Moporators

User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

Quite long shit but I've bolded the uselfull shit:

while ( $replay = mysql_fetch_array( $replays ) ) {
echo "<tr class='normal'><td class='"; if ( $replay[ 'Time' ] == $besttime[ 'Time' ] ) { echo "best"; } else { echo "normal"; } echo "'>" . $replay[ 'inLevel' ] . "</td><td class='"; if ( $replay[ 'Time' ] == $besttime[ 'Time' ] ) { echo "best"; } else { echo "normal"; } echo "'>" . $replay[ Time ] . "</td><td class='"; if ( $replay[ 'Time' ] == $besttime[ 'Time' ] ) { echo "best"; } else { echo "normal"; } echo "'>"; if ( $daydiff == 0 ) { echo "Today"; } elseif ( $daydiff == 1 ) { echo "Yesterday"; } else { echo $daydiff . " days ago"; } echo "</td><td class='"; if ( $replay[ 'Time' ] == $besttime[ 'Time' ] ) { echo "best"; } else { echo "normal"; } echo "'>" . $replay[ 'Username' ] . "</td><td class='"; if ( $replay[ 'Time' ] == $besttime[ 'Time' ] ) { echo "best"; } else { echo "normal"; } echo "'>"; if ( $time_chars > 8 ) { echo "<form action='share_Replay.php' method='post'><input type='hidden' name='level' value='" . $replay[ 'inLevel' ] . "'><input class='sharing_input' type='submit' value='Unshare'>"; } else { echo "<form action='share_Replay.php' method='post'><input type='hidden' name='level' value='" . $replay[ 'inLevel' ] . "'><input class='sharing_input' type='submit' value='Share'>"; } echo "</td></tr>";
}

Now as you can see I want the <input type='hidden' name='level' value='" . $replay[ 'inLevel' ] . "'> to show the special level, not the same one. Bah hard to explain...

Do you understand?
Team HotHorses, and I'm converting to Icelandian now...
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

Ugh hard to read, but maybe try putting a </form> there too?
In the share_Replay.php script you should try a print_r($_POST); and see what values are being submitted.
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

skint0r wrote:Ugh hard to read, but maybe try putting a </form> there too?
In the share_Replay.php script you should try a print_r($_POST); and see what values are being submitted.
Haha, cant believe I forgot the </form> :D! It works now, thanks maaan :P
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:

Post by niN »

Does anyone know how to make a url from a sub folder to a previous folder? for example:

How do I link a guy who's located in: "/My/New/Dir/" to "/My/New/start.php"?

Understand what I mean?
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:

Post by The_BoneLESS »

i think i'm wrong but i recall something like puting a dot to get back a notch in folder structure :

Ex: url="./folder/file.txt"

but, i'm really not sure about that...

EDIT: I've read some stuff, there are also some stuff with 2 dots

url="../folder/bla.txt"
haven't really understood but, check those techniques
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
User avatar
zworqy
Kuski
Posts: 3706
Joined: 19 May 2002, 23:17
Location: Lilla Edet, Sweden
Contact:

Post by zworqy »

one dot = current folder
two dots = one folder up

basic DOS stuff :P
<Fihlvein> another case of zworqy-is-always-right closed i guess
<yoosef> zworqy doesnt suck at anything
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

I find that using those ../ links gets confusing, and should you ever move stuff around it will make everything harder. Having moved from webhost to webhost numerous times with million of different sites and directories, in my experience the best thing is to use relative links -- i.e. /bulle/max etc. Well guess it's a personal preference anyway.

My best suggestion would be to learn how to use Apache's great mod_rewrite module, which I've started using absolutely everywhere. In essence, it lets you make virtual links which are friendlier to both the user and search engines (if you care about that stuff). i.e. www.bulle.com/user/ruelze/ would actually be www.bulle.com/index.php?page=user&id=ruelze for instance.

If that makes any sense :P
Prestigious member of 14.6x Tutor14 club
User avatar
zworqy
Kuski
Posts: 3706
Joined: 19 May 2002, 23:17
Location: Lilla Edet, Sweden
Contact:

Post by zworqy »

skint0r wrote:I find that using those ../ links gets confusing, and should you ever move stuff around it will make everything harder. Having moved from webhost to webhost numerous times with million of different sites and directories, in my experience the best thing is to use relative links -- i.e. /bulle/max etc. Well guess it's a personal preference anyway.
But dots ARE (parts of) relative links :?
<Fihlvein> another case of zworqy-is-always-right closed i guess
<yoosef> zworqy doesnt suck at anything
User avatar
skint0r
39mins club
Posts: 768
Joined: 16 Jun 2002, 07:36
Location: Oslo, Norway

Post by skint0r »

Relative to the root then, if you want to be anal about it.
Prestigious member of 14.6x Tutor14 club
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

skint0r wrote:I find that using those ../ links gets confusing, and should you ever move stuff around it will make everything harder. Having moved from webhost to webhost numerous times with million of different sites and directories, in my experience the best thing is to use relative links -- i.e. /bulle/max etc. Well guess it's a personal preference anyway.

My best suggestion would be to learn how to use Apache's great mod_rewrite module, which I've started using absolutely everywhere. In essence, it lets you make virtual links which are friendlier to both the user and search engines (if you care about that stuff). i.e. www.bulle.com/user/ruelze/ would actually be www.bulle.com/index.php?page=user&id=ruelze for instance.

If that makes any sense :P
Okay thanks mate, I was wondering how you did that! Thought you used folders and all =P. Cheers, will learn!

Oh and btw. "The sky's the limit" was a good choice of chorus ;)
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:

Post by niN »

About my site www.creapple.se
tijsjoris wrote:nIN, you might take a look at your site with opera browser; it doesn't look right. :?
I've noticed that IE and other browsers requires different codes for them to work. Check that link up there for example, in Mozilla Firefox, everything works fine! But in Internet Explorer some blue url lines are shown on the url images in the menu. And as tj said, in Opera it's all fucked up.

How can I provent this from happening? of course I don't want my graphics to be fucked up for some visitors just because they use different browsers...

I know it has to do with the css file... But I just dont know how to fix it.
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:

Post by niN »

I have another problem concerning MySQL and PHP. People have added say ten times to my database. Now, how can I know which time is the second best, and the fifth best, and the 9th best etc.? I want a script that can rank the times, and tell me what place/position $time['BoneLESS'] (for example) is on, or $time['Mawane']. I've never understood how to do this.

d'you understand?
Team HotHorses, and I'm converting to Icelandian now...
User avatar
Mawane
Kuski
Posts: 3299
Joined: 15 Apr 2007, 01:05
Team: SV
Contact:

Post by Mawane »

sorry man, i can be the guinea pig to test the site but i can't be the laboratory technician :wink:
Website || TT:41:45:64 || Team Image
Image[url=steam://friends/add/76561198025490048]Image[/url]
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:

Post by The_BoneLESS »

well, you could simply put all the times in one array (table) and do some sorting (bubble sortcould be fine for that)

only thing would the comparison between times, don't think it would sort times with a pattern like xx;xx;xx. Maybe you would have to convert times in milliseconds or seconds.

Clearly, skint and kopaka could be quite useful here as they have both made sites with what you are looking for.
Website || TT:38:05:33 || WC5:15th || HHIT for life || 9th world wide ... BAP is next
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:

Post by Kopaka »

What I do, is that each time you upload a record it reads which placement all the times are in that level and adds that to the database so it's easy to use elsewhere on the site. This is the function I use for that:

Code: Select all

function numbers($thelevel){
	$number = 1;
	$numbers = mysql_query("SELECT * FROM times WHERE times.$thelevel IS NOT NULL ORDER BY times.$thelevel ASC") or die(mysql_error());
	while($row = mysql_fetch_array( $numbers )){
		$user = $row['username'];
		mysql_query("UPDATE ks_numbers SET $thelevel = '$number' WHERE username = '$user'") or die(mysql_error());
		$number++;
	}
}
My table is build up in some mongo way though.


Or you could make some function that finds the placements each time you need it, I use something like that for kinglist placement on userpages

Code: Select all

$nick = "niN"; <- ect.
$no = 1;
$kingpoints = mysql_query("SELECT * FROM ks_kinglist WHERE kinglist IS NOT NULL ORDER BY kinglist DESC") or die(mysql_error());
while($row = mysql_fetch_array( $kingpoints )){
	$checkpoints = $row['kinglist'];
	$klnick = $row['username'];
	if($klnick == $nick){
		$klno = "$no.";
		$klpoints = $checkpoints;
		break;
	}else{
		$no++;
	}
}
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

Kopaka wrote:

Code: Select all

function numbers($thelevel){
	$number = 1;
	$numbers = mysql_query("SELECT * FROM times WHERE times.$thelevel IS NOT NULL ORDER BY times.$thelevel ASC") or die(mysql_error());
	while($row = mysql_fetch_array( $numbers )){
		$user = $row['username'];
		mysql_query("UPDATE ks_numbers SET $thelevel = '$number' WHERE username = '$user'") or die(mysql_error());
		$number++;
	}
}
Ok, I know some php basics and I might even go a bit further and say I can handle php rather well. However, since I learnt php by trying I am rather ignorant on the subject. Having said that I have a few questions.

I understood the script above like this (please correct me if I'm wrong): when one run the script, it orders the current times in the database, and then find a row. However due to my ignorance in the subject I don't know what "WHERE times.$thelevel IS NOT NULL" means. Anyways, after having found that row, it updates the column "numbers/ranking" from nickname "$row['username']" to the bottom of the ordered times. That way each uploaded time gets a value for which position it deserves when it's being uploaded, and that way I can create a kinglist in the future.

Am I correct?

What I described above should be very useful for me, if I could only understand it a bit more. Maybe I already understand it, and then all you really have to explain is this: "WHERE times.$thelevel IS NOT NULL". Would apprechiate another reply, and thanks for your support! :)
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:

Post by Kopaka »

Yes you're correct.

"WHERE times.$thelevel IS NOT NULL" simply means that it only finds the times that is not null, meaning those people who doesn't have a time in that level doesn't get added.
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

Kopaka wrote:Yes you're correct.

"WHERE times.$thelevel IS NOT NULL" simply means that it only finds the times that is not null, meaning those people who doesn't have a time in that level doesn't get added.
ok thank you very much! however, I do not understand why that would be nessecary since the 'levs' database never contain a row without a time. But can I change that part to:

Code: Select all

function numbers($thelevel){
   $number = 1;
   $numbers = mysql_query("SELECT * FROM times WHERE lev='$thelevel' ORDER BY times ASC") or die(mysql_error());
   while($row = mysql_fetch_array( $numbers )){
      $user = $row['username'];
      mysql_query("UPDATE ks_numbers SET $thelevel = '$number' WHERE username = '$user'") or die(mysql_error());
      $number++;
   }
}
This is how I would write the script, and I will try it out now :) Thanks in advance kopa! you're a star!
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:

Post by niN »

okay, I tried it and it didn't work :( In my database I added a column with the name: "pos" and then I wrote this into my replay handling script (I placed it after the codes where I'd written the time, lev and nick info in to the times database already)

Code: Select all


function numbers($thelevel){
   $numb = 1;
   $numbers = mysql_query("SELECT * FROM nindex WHERE lev='$thelevel' ORDER BY times ASC");
   while($rowg = mysql_fetch_array( $numbers )){
      $userr = $row['nick'];
      mysql_query("UPDATE nindex SET pos = '$numb' WHERE nick = '$userr'");
      $numb++;
    }

  }
What could be wrong?
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:

Post by The_BoneLESS »

maybe you just didn't copy your code right but, you first use

while( $rowg = ...

on the next line, you use $row

there's a g that shouldn't be there...

and if that is not the problem, could you detail a bit more your "it doesn't work" ?
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:

Post by niN »

The_BoneLESS wrote:maybe you just didn't copy your code right but, you first use

while( $rowg = ...

on the next line, you use $row

there's a g that shouldn't be there...

and if that is not the problem, could you detail a bit more your "it doesn't work" ?
oh, thank you. I changed it to:

Code: Select all


function numbers($thelevel){
   $numb = 1;
   $numbers = mysql_query("SELECT * FROM nindex WHERE lev='$thelevel' ORDER BY times ASC");
   while($row = mysql_fetch_array( $numbers )){
      $userr = $row['nick'];
      mysql_query("UPDATE nindex SET pos = '$numb' WHERE nick = '$userr'");
      $numb++;
    }

  }
but it didn't work either. What I want this script above to do, is to find the row which I just wrote to the database (with my replay handler script), and then find out what place it deserves. Write the number that the rec is ranked in the 'pos' column and update the same column in every row below mine but adding one each time. However, this script doesn't write anything to the database.
Team HotHorses, and I'm converting to Icelandian now...
User avatar
totem
39mins club
Posts: 328
Joined: 26 Dec 2007, 14:04

Post by totem »

what you ALWAYS have to do when coding is to get some debug info.
Are you sure your query returns something ? are you sure the level name is well-formated ? e.g. here you should print some "hello" in the fetch loop to be sure you don't process an empty array
anyway your algorithm seems to be okay even if i can't figure out the way you designed your database
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

totem wrote:what you ALWAYS have to do when coding is to get some debug info.
Are you sure your query returns something ? are you sure the level name is well-formated ? e.g. here you should print some "hello" in the fetch loop to be sure you don't process an empty array
anyway your algorithm seems to be okay even if i can't figure out the way you designed your database
Yeah I guess that would be rather smart! Thanks for that useful piece of info :)

About the way I designed my database: I just did whatever works :P I have no idea what's what etc. I just tried to build up a table as best I can. anywz, thanks! I'll try to soulve it now.
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:

Post by Kopaka »

You can also try adding "or die(mysql_error())" to the lines with mysql queries, that way you get an error message if there's anything wrong with the mysql code
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

Kopaka wrote:You can also try adding "or die(mysql_error())" to the lines with mysql queries, that way you get an error message if there's anything wrong with the mysql code
willkeep in mind, thanks :)
Team HotHorses, and I'm converting to Icelandian now...
User avatar
totem
39mins club
Posts: 328
Joined: 26 Dec 2007, 14:04

Post by totem »

niN wrote:I just tried to build up a table as best I can.
you mean you've got only one table for the whole site ?
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Post by niN »

totem wrote:
niN wrote:I just tried to build up a table as best I can.
you mean you've got only one table for the whole site ?
nene of course not :P But I try to use as little tables as possible to avoid complications.
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:

Post by niN »

YES! It works now :D Big thanks kopaka! Kinglist coming next!
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:

Post by niN »

niN wrote:YES! It works now :D Big thanks kopaka! Kinglist coming next!
hum.. it wasn't as easy as I thought to make that. Now that I know what position the time is worth, how do I keep an updated kinglist in a table in my database? I want the top 50 to get points. Please help me out kopaka! I know I can't do it the same way as I did before since the points wont change by 1 every time. Maybe there's some simple way I'm missing here, but don't thinkg so.
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 »

Use an array to get the kinglist points appointed to certain placement.

Code: Select all

$klpoints = array("1" => "50", "2" => "45", "3" => "40", "4" => "35", "5" => "30");

function kinglist($level){
   $numb = 1;
   $numbers = mysql_query("SELECT * FROM nindex WHERE lev='$level' ORDER BY times ASC");
   while($row = mysql_fetch_array( $numbers )){
      $userr = $row['nick'];
      $points = $klpoints[$numb];
      mysql_query("UPDATE nindex SET kinglist = '$numb' WHERE nick = '$userr'");
      $numb++;
    }

  }
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Re: HTML helping

Post by niN »

Thanks kop! I will try that on friday when I come home from my survival course.
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 »

For some reason this:

Code: Select all


  if( $rem_b == 'nin' ) {

   $klpoints = array("1" => "125", "2" => "105", "3" => "94", "4" => "86", "5" => "79", "6" => "72", "7" => "66", "8" => "60", "9" => "55", "10" => "50", "11" => "46", "12" => "43", "13" => "39", "14" => "36", "15" => "33", "16" => "30", "17" => "28", "18" => "26", "19" => "24", "20" => "22", "21" => "20", "22" => "19", "23" => "18", "24" => "17", "25" => "16", "26" => "15", "27" => "14", "28" => "13", "29" => "12", "30" => "11", "31" => "10", "32" => "9,5", "33" => "9", "34" => "8,5", "35" => "8", "36" => "7,5", "37" => "7", "38" => "6,5", "39" => "6", "40" => "5,5", "41" => "5", "42" => "4,5", "43" => "4", "44" => "3,5", "45" => "3", "46" => "2,5", "47" => "2", "48" => "1,5", "49" => "1", "50" => "0,5");

   $numba = 1;
   $numbaers = mysql_query("SELECT * FROM nindexpts WHERE lev='$level' ORDER BY pos ASC") or die(mysql_error());
   while($rowt = mysql_fetch_array( $numbaers )){

      $userrb = $_COOKIE[ 'registered' ];
      $points = $klpoints[$numba];
      mysql_query("UPDATE nindexpts SET pts = '$klpoints[$numba]' WHERE nick = '$userrb'");
      $numba++;
    }
   }
Won't work... It will only write the points of the WORST ranked time in to MY column ONLY (even though my time might be best etc). What's wrong :(?
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 »

Since you get $userrb from $_COOKIE[ 'registered' ], it's kinda obvious it will always give you the points, so it gives you 125 first, then 105, down to 0,5. Instead of the $userrb = $_COOKIE[ 'registered' ]; line you should write some $userrb = $rowt['nick'];
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Re: HTML helping

Post by niN »

Kopaka wrote:Since you get $userrb from $_COOKIE[ 'registered' ], it's kinda obvious it will always give you the points, so it gives you 125 first, then 105, down to 0,5. Instead of the $userrb = $_COOKIE[ 'registered' ]; line you should write some $userrb = $rowt['nick'];
It worked! Millions of thank you:s! I will get the kinglist working today.
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 »

I have another question, what if you want to get info from normal text, forward that info to another document where you save the info as $textinfo and for instance insert $textinfo to a row in a database? Normally you would use forms to send info between pages, and the $_POST[ 'textinfo' ] to save the info to a variable, but what if you just want to use a normal url and not an entire form?

This could be useful in for instance: giving every level their own individual page on a website, every user his own individual stats (so that when a player klicks some $other_players_nick he comes to a page showing all times from my database where nick is $other_players_nick). Am I making any sence?
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 »

Yeah, you can use that thing I use with ?nick=Kopaka ect. in the url.

So the link to a level on frontpage ect. can be made like this:

Code: Select all

$level = nin0030.lev
<a href='http://creapple.se/nindex/?level=$level'>$level</a>
And on the page for levels you make this:

Code: Select all

$level = $_GET["level"];
and then you have the levelname as a variable and can use that to find info from database ect.
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Re: HTML helping

Post by niN »

Kopaka wrote:Yeah, you can use that thing I use with ?nick=Kopaka ect. in the url.

So the link to a level on frontpage ect. can be made like this:

Code: Select all

$level = nin0030.lev
<a href='http://creapple.se/nindex/?level=$level'>$level</a>
And on the page for levels you make this:

Code: Select all

$level = $_GET["level"];
and then you have the levelname as a variable and can use that to find info from database ect.
I understood it as this: You save info to the url, and when you are being forwarded to the new page you use $_GET["level"] (because it says ?level=$level in the url) to get the info from the url. Sounds smart! I'll give it a try, thanks matey!
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 »

you got it right!

you can make link like
<a href="./yourpage.php?level=$level" .... ></a>
or multiple infos with the " & " symbol (see in the actual lauta URL) like:
<a href="./yourpage.php?level=$level&id=$id" .... ></a>

when you use POST, you send/receive datas from the form (inputs) and
when you use GET, you send/receive datas from the URL.

The choice is mainly about security as GET is very unsafe so, only transfer "not important" datas with that (no passwords!)
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 »

The_BoneLESS wrote:you got it right!

you can make link like
<a href="./yourpage.php?level=$level" .... ></a>
or multiple infos with the " & " symbol (see in the actual lauta URL) like:
<a href="./yourpage.php?level=$level&id=$id" .... ></a>

when you use POST, you send/receive datas from the form (inputs) and
when you use GET, you send/receive datas from the URL.

The choice is mainly about security as GET is very unsafe so, only transfer "not important" datas with that (no passwords!)
Thanks boneless! I used it for the website and it worked better than I ever could imagine!
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 »

skint0rs and viperkillerguy's replay info script, the script which they created to ger time and lev from a replay, gets info from single player rides. Would it be possible to extend this script and make it possible to see if the replay driven on is Multiplayer or Singleplayer? I couldn't do it, but could someone else do it?
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 »

I've been trying to soulve a prob for quite some time now. Hopefully you can help!

I am making a site for a bunch of my friends, for them to use on their server. Their server does not support MySQL and it doesn't have a database. Though they still need info in tables, for instance a list of all available downloads. Instead of using a database to store the info in, I stored the info in a textdocument, using an X mark to set the columns. The textdocument looks like this:

Code: Select all

DATE×URL×USER×DESCRIPTION×HITS×
DATE×URL×USER×DESCRIPTION×HITS×
(etc.)
Then, each time a fellow uploads a file another one of these lines is added to the textdocument with the current info, and each time someone downloads the file, the downloaded file's ×HITS× column will be added with one. I then use some php codes to get the info from that textdocument, and explode every X mark so that I know where the column ends etc. Like this:

Code: Select all

   <table>
   <tr>
   <td colspan="3">All Uploads</td>
   </tr>
   <?php 
   $lines = file( "txts/uploads_info.txt" );

      for( $i = 0; $i < count($lines); $i++ ) { 

      $data = explode( '×', $lines[$i] ); 

      echo "
      <tr>
      <td>".$data[0]."</td>
      <td>".$data[1]."</td>
      <td><a href='user.php?user=".$data[2]."'>".$data[2]."</a></td>
      </tr>"; 

      } 

   ?>
   </table>
Now, this would show the entire content of the file: txts/uploads_info.txt from the begginning to the end (and it does). But say I wanted to make a list of top ten downloads, containing the top ten most popular downloads. This list would have to be ordered by the hits that the line has got, by the column ×HITS×. How do I change my current PHP code, into one that would make the outcome become an ordered list, from most hits to least hits?

If you don't understand what I mean, the corresponding code to soulve my problem with MySQL would look like this:

Code: Select all

   $Top_Ten_Downloads = mysql_query( "SELECT * FROM uploads_info ORDER BY HITS DESC LIMIT 0, 10" );
Please help me, because I'm stuck here! Remember I'm using a text document to get the info from, not a database!
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 »

well, first of all, you need to place all your infos in a 2d table. so, something like this...

Code: Select all

<?php
      ...
      $aLines = array();
      $lines = file( "txts/uploads_info.txt" );
     
      for( $i = 0; $i < count($lines); $i++ ) {

      $data = explode( '×', $lines[$i] );
      $aInfos = array();
      $aInfos= array("date" => $data[0], "url" => $data[1], "user" => $data[2], "desc" => $data[3], "hits" => $data[4]);
      array_push($aLines , $aInfos);     //pushes $aInfos array into the $aTest array
      
      }
      ...
?>
Haven't tested but, should work.
So now, you would have all your lines in a single 2D array.
All that's left to do is to sort the table. Being 2 dimensional, it's a little more complex but, i used recently a function found on the internet that was quite helpful...
here it is:

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);
		}
    }
?>
so that's the function, it returns the array, sorted.

You can use it this way:

Code: Select all

$aSorted = array();
$aSorted = msort($aLines, "hits", false)
$aSorted = msort($aLines) //or like this as the default values are already ok
Once you've got that, you can go through the first 10 elements of the newly sorted table to get the top10 most popular.

Another thing: text files can be useful to store data quickly but, if you want to modify the datas, i would recommend using XML files, very structured and easier to access datas. ( introduction to XML )
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 »

I had some problem understanding the code above since I'm not that good at php. But I tried, and failed. I simply copied everything into my php document in the order you advised me to, but I didn't know what to do next. I understood the codes like this: those lines of php sorts out the HITS column in my text document for me, and put them in an array. What do I do now to get that array into a table with every other info from the textdocument like: USER, URL etc?

Thanks for your help even BoneLESS!

EDIT: I got it working, Thanks BoneLESS :D
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 »

nice to see that i helped!

just to clear things up.

the first snippet simply makes a 2D table (pretty much like a database table).
the msort function does the same job as your "ORDER BY HITS DESC" part of the SQL. It sorts the entire table with the HITS key.

et voilà!
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 »

Hey BoneLESS, or Kopaka I need help again :)

First:
I want to know how to select a specific phrase/row in a textdocument with PHP. For instance, let's say I use the same document as before:

Code: Select all

DATE1×URL1×USER1×DESCRIPTION1×HITS1×
DATE2×URL2×USER2×DESCRIPTION2×HITS2×
(etc.)
How can I select all info from the row with DATE2? The corresponding code with MySQL would be:

Code: Select all

$specific_row = mysql_query( "SELECT * FROM uploads_info WHERE DATE2='23-02-2008'" );
What I could do, is to fread() X bytes until I get to the info I wants, but I can't do this if I don't know which bytes exist etc. (if I don't know exactly how many letters the text document has in it). So that won't work here.

I should probably create a 2d table, like before, only this time with the row containing DATE2 at the top, and then limit the loop to 1 so that only that row will be shown. Only, how do I do this?

Second:
Now, say I wanted to replace HITS2 in the row with DATE2 with a new variable (but leave all other columns/info in the textdocument untouched). How can I write something to a specific place in a textdocument, instead of writing it to the end of it?

Thanks very much for your help :)!
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 »

Soulved A but not B :P

I need to know how to erase X from a textdocument with PHP basically, where X is a specific text. :P Someone knows how to do it?
Team HotHorses, and I'm converting to Icelandian now...
User avatar
benson
Kuski
Posts: 49
Joined: 21 Oct 2004, 15:35
Location: Hong Kong
Contact:

Re: HTML helping

Post by benson »

niN wrote:Soulved A but not B :P

I need to know how to erase X from a textdocument with PHP basically, where X is a specific text. :P Someone knows how to do it?
for me, I would read the whole file by file_get_contents and then use str_replace to delete it.. finally write all the content back to the file.. perhaps it is a stupid way..
Hoping Elma can spread in Hong Kong... but... nearly impossible
[JAB] TT: 53:57:14...
User avatar
niN
Kuski
Posts: 2631
Joined: 22 Aug 2005, 12:23
Team: HoHo
Location: Sweden, Gothemburg
Contact:

Re: HTML helping

Post by niN »

benson wrote:
niN wrote:Soulved A but not B :P

I need to know how to erase X from a textdocument with PHP basically, where X is a specific text. :P Someone knows how to do it?
for me, I would read the whole file by file_get_contents and then use str_replace to delete it.. finally write all the content back to the file.. perhaps it is a stupid way..
Seems really smart! I haven't tested but if it works you have saved me. Thanks ben!
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 »

If you guys want to see my proudest project it's this:

http://comstg.luben.se/

It doesn't use a database but a text document to store info. It's been hard work finishing it but it's done now :) Only certain users can upload files (none of you I'm afraid).
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 »

I have a question! How can I make a table background fade away from blue to white for instance? is it possible with css or do I need to use java?

And is it also possible to do this on borders? To make a border fade from white to red in 5 seconds?

Help is very much appreciated :)
Team HotHorses, and I'm converting to Icelandian now...
Post Reply