 |
Account Login
|
 |
 |
Latest Articles
|
 |
 |
IRC Channel
|
 |
 |
Associates
|
 |
 |
Associates
|
 |
|
 |
|
 |
|
 |
10-29-2007, 03:55 AM
|
#1 (permalink)
|
|
The Acquainted
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
|
Your old code?
Well, I was feeling a bit bored and nostalgic, so I went through all my threads at various forums, and found all my design and PHP work I did back then. Here is the PHP work I found, thought you guys might enjoy seeing how horrible I was. This was from over 2 years ago (August/September '05). I'm rather sad knowing I could have kept coding PHP, and be pretty good by now.
This script never did work, by the way. Now I see why. :)
(I'm just linking to my site since they are rather long and have HTML code mixed in for forms)
http://www.psdtocode.com/old.phps
http://www.psdtocode.com/old2.phps
|
|
|
10-29-2007, 10:18 AM
|
#2 (permalink)
|
|
Super Moderator
Join Date: Sep 2007
Posts: 165
Thanks: 0
|
Lol ouch, i do not have the code but when i was learning i use to have switches and paste the entire html template into each switch case like:
PHP Code:
switch ($state) { case "home": //full html doc and php inserting variables, including header and footer. no includes, just copy + paste html break; case "account": //full html doc and php inserting variables, including header and footer no inlcudes just copy + paste html break; }
Note this was like 2002 and i would of been like 14... lol
|
|
|
|
11-29-2007, 06:07 PM
|
#3 (permalink)
|
|
The Acquainted
Join Date: Nov 2007
Posts: 127
Thanks: 14
|
Quote:
Originally Posted by bluesaga
PHP Code:
switch ($state)
{
case "home":
//full html doc and php inserting variables, including header and footer. no includes, just copy + paste html
break;
case "account":
//full html doc and php inserting variables, including header and footer no inlcudes just copy + paste html
break;
}
|
LOL
When I first got into PHP, a friend of mine told me how he made all of his dynamic sites using only one file (index.php). I couldn't believe my eyes! I was amazed and used it on a few sites until I saw the downfall. Although, my index.php used if statements as if they were going out of style. Actually, I didn't even know what a switch statement was either. The worse part of it all was that I didn't put a common header and footer in my index.php. Each 'page' would contain EVERYTHING including the doctype. Needless to say, updating my site sucked ass.
Not too long later, someone told me about seperating my header and footer into their own entity and simply including them on the top and bottom of my script. I nearly soiled mysql when I learned this nifty trick.
:)
|
|
|
|
10-29-2007, 01:20 PM
|
#4 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Lol. I remember I always used to use <?=$myVariable; ?> when I was coding years ago. I must dig out some of my old code though! I'm sure it'll tickle you all.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
10-29-2007, 04:00 PM
|
#5 (permalink)
|
|
The Wanderer
Join Date: Oct 2007
Posts: 20
Thanks: 0
|
My old code would be something like this:
PHP Code:
<?php include('connect.php'); global $db;
if($db == null){ die('LOL! You could not connect to DB!!! LOL!!'); }
if($_POST['submit']){ $HUGELISTOFVARIABLES = $_POST['stuff'];
$result = mysql_query('SOME HUGE QUERY'); if($result){ echo "AWESOME! LOL!!!"; } }else{ //HUGE FORM HTML } ?>
as compared to now:
PHP Code:
<?php class template { private $code;
public function __construct ( $szFile ) { $this->code = file_get_contents($szFile); } public function replaceVars ( $aVars ) { foreach ( $aVars as $key => $value ) { $this->code = str_replace($key, $value, $this->code); } } public function publish ( ) { echo $this->code; } } /*** * Example Usuage: $tpl = new template('templates/xtc.tpl'); $tpl->replaceVars(array('HOME_URL' => 'http://www.google.com')); $tpl->publish(); */ ?>
|
|
|
|
10-29-2007, 06:05 PM
|
#6 (permalink)
|
|
The Frequenter
Join Date: Sep 2007
Posts: 360
Thanks: 24
|
PHP Code:
<?php echo 'Hello World'; ?>
I started out with echos.
|
|
|
|
10-29-2007, 09:51 PM
|
#7 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Quote:
Originally Posted by Haris
PHP Code:
<?php echo 'Hello World'; ?>
I started out with echos.
|
I don't get it. What's wrong with echoes?
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
10-29-2007, 09:32 PM
|
#8 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Yeah, I used to mix all my PHP with my HTML. Lovely stuff!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
10-29-2007, 10:29 PM
|
#9 (permalink)
|
|
The Acquainted
Join Date: Sep 2007
Location: Arizona
Posts: 114
Thanks: 10
|
He was saying that is how he started coding, with the basic Hello World script.
Also, on the Chatwebdev IRC channel, Dread (a great PHP coder), and Shaun were also digging out their old code, too. See what I started? :)
|
|
|
11-29-2007, 06:47 PM
|
#11 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
I'd be toooo embarrassed to post my code, but lets say i didnt bother seperating presentation from logic
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|
11-29-2007, 09:25 PM
|
#12 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Quote:
Originally Posted by sketchMedia
I'd be toooo embarrassed to post my code, but lets say i didnt bother seperating presentation from logic
|
Oh go on! If my PC actually worked without me kicking it to get its hard-drives whirring again, I'd pull up some of my old code  .
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
11-29-2007, 11:29 PM
|
#13 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
ok, I'll see what i can find. 
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|
11-30-2007, 02:30 AM
|
#14 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
I'll get the tissues ready for when laughter results in tears!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
12-01-2007, 04:40 PM
|
#15 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Hehe. I found some of my old code. This is a snippet from my Javascript hangman game which is still quite addictive! The RAR file is dated the 12th of Match, 2006, so you can see how far I've come. Without further ado:
(I would edit the DB details, but it's years old anyway.)
php Code:
define('MS_GAME', 'GAME'. substr(rand(99999, 10000). ip2long($_SERVER[ 'REMOTE_ADDR'] ), 0, 12)); define('MYSQL_USER', 'adam_mine05user'); define('MYSQL_PASS', 'sYi3haVveV39qQ'); define('MYSQL_HOST', 'localhost'); define('MYSQL_DB', 'adam_minesweeper'); ini_set('max_execution_time', '120'); $minesweeperSQL = @ mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS ) or die('<div style="font-size: 10px; font-family: Tahoma, Verdana, Helvetica">MySQL Server not responding.</div>'); @ mysql_select_db(MYSQL_DB ) or die('<div style="font-size: 10px; font-family: Tahoma, Verdana, Helvetica">MySQL database "'.MYSQL_DB. '" does not exist.</div>'); if(isset($_GET[ 'records'] )) { $level = mysql_real_escape_string(strip_tags($_GET[ 'records'] )); $sql = "SELECT rName, rTime FROM `records` WHERE rLevel = '$level' ORDER BY rTime ASC LIMIT 0,10"; $resultsRS = mysql_query($sql); $records = '<table id="records"><tr id="record"><th style="width: 10px"></th><th style="width: 120px">Name</th><th>Time (Seconds)</th>'; $n = 1; while($row = mysql_fetch_array($resultsRS)) { $records .= '<tr><td>'. $n. '</td><td>'. $row[ 'rName']. '</td><td>'. $row[ 'rTime']. '</td></tr>'; $n++; } $records .= '</tr></table>'; echo $records; mysql_free_result($resultsRS); die(); } elseif(isset($_GET[ 'name'] ) && isset($_GET[ 'seconds'] )) { function microtime_float () { list($usec, $sec) = explode(" ", microtime()); return ((float )$usec + (float )$sec); } $time_start = mysql_real_escape_string(strip_tags($_GET[ 'seconds'] )); $time_end = microtime_float (); $time = $time_end - $time_start; $name = substr(mysql_real_escape_string(strip_tags($_GET[ 'name'] )), 0, 40); $level = mysql_real_escape_string(strip_tags($_GET[ 'level'] )); $level = $_GET[ 'level']; setcookie('Minesweeper', $name); $sql = "INSERT INTO `records` (rName, rLevel, rTime) VALUES ('$name', '$level', '$time')"; mysql_query($sql); } elseif(isset($_GET[ 'cell'] ) && isset($_GET[ 'game'] )) { $cell = substr(mysql_real_escape_string($_GET[ 'cell'] ), 0, 3); $game = $_GET[ 'game']; $sql = "SELECT `gValue` FROM `game` WHERE gCell = '$cell' AND gID = '$game'"; $resultsRS = mysql_query($sql); $row = mysql_fetch_array($resultsRS); if($row == 0) { echo $row[ 0]; } elseif($row[ 0] == 'Mine') { echo $row[ 0]; die(); } else { switch($row[ 0] ) { case(1): $number = 1; $colour = '#5B35FF'; break; case(2): $number = 2; $colour = '#007103'; break; case(3): $number = 3; $colour = '#FF3535'; break; case(4): $number = 4; $colour = '#002B8C'; break; case(5): $number = 5; $colour = '#910202'; break; case(6): $number = 6; $colour = '#00A997'; break; case(7): $number = 7; $colour = '#000000'; break; case(8): $number = 8; $colour = '#CB9900'; break; default; $number = 0; $colour = '#000000'; break; } } echo '<font color="'. $colour. '">'. $number. '</font>'; mysql_free_result($resultsRS); die(); }
Hopefully I've laid a foundation  Don't be shy anybody!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
12-01-2007, 06:13 PM
|
#16 (permalink)
|
|
The Acquainted
Join Date: Sep 2007
Posts: 133
Thanks: 6
|
That's pretty cool, i lost all my old code, not sure where i went :(
The oldest code i have is about a year old which as my original social networking site, but that's a secret ;)
|
|
|
12-01-2007, 07:56 PM
|
#17 (permalink)
|
|
The Frequenter
Join Date: Sep 2007
Posts: 360
Thanks: 24
|
php Code:
<?php// Last Modified 18th Augustinclude('templates/header.php'); // Header templateinclude('config/config.php'); // Includes configuration filesinclude('lib/functions.php'); // Load all functions from Library$select_questions = mysql_query("SELECT * FROM questions") or die(mysql_error()); while($row = mysql_fetch_array($select_questions, MYSQL_BOTH )){ $questions = $row[ 'question']; $qID = $row[ 'id']; if($_POST[ $qID] == "Positive"){ $_POST[ $qID] = 1; } elseif($_POST[ $qID] == "Negative"){ $_POST[ $qID] = 2; } else{ $_POST[ $qID] = 3; } $posted_answer[] = $_POST[ $qID]; }$submit_useranswer = $_POST[ 'submit_useranswers']; if(isset($submit_useranswer)){ $user_answer[] = $posted_answer; echo '<h2>Top three nearest candidates based on your answers</h2>'; include('templates/table.php'); }include('templates/footer.php'); // Footer Template?>
|
|
|
|
12-01-2007, 08:12 PM
|
#18 (permalink)
|
|
The Prestige
Join Date: Oct 2007
Location: Manchester, UK
Posts: 854
Thanks: 32
|
I cant actually find the code, i think if was lost when my last HD packed in.
But the script was someting i wrote for the CoD1/2 game server hosting company i used to run.
It was basically the order form, it had about 6 different forms on it and it was ALL in one php file with a switch at the top, with HTML/CSS and PHP mixed all over the shop.
It was a right mess and a nightmare to maintain, as you can imagine.
If i do find it i will post it.
__________________
mysql> SELECT * FROM `users` WHERE `users`.`clue` > 0;
Empty set (0.00 sec)
|
|
|
|
12-04-2007, 04:03 AM
|
#19 (permalink)
|
|
La Vida es Sueño
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
|
Not too bad, Haris. At least you're sectioning off different code. I think mine looks a lot worse than yours. Can definitely see how far we've come when you look over your old code!
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
|
|
|
12-04-2007, 04:16 AM
|
#20 (permalink)
|
|
The Frequenter
Join Date: Sep 2007
Posts: 360
Thanks: 24
|
Quote:
Originally Posted by Wildhoney
Not too bad, Haris. At least you're sectioning off different code. I think mine looks a lot worse than yours. Can definitely see how far we've come when you look over your old code!
|
I think it's because I had joined a proper community (TalkPHP) that helped me program things correctly. 
|
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Hybrid Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|