9 Replies - 675 Views - Last Post: 06 October 2008 - 01:26 AM Rate Topic: -----

#1 akozlik  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 90
  • View blog
  • Posts: 797
  • Joined: 25-February 08

Tutorial Week!

Posted 03 October 2008 - 06:40 AM

Hey everyone,

I was talking with pemcconnell in a different thread and we were talking about the number of PHP tutorials that have appeared on this site. The PHP tutorials now have the second highest total on the site.

We were discussing possibly doing a tutorial week, where we try to put get as many tutorials up as we can, to try to catch up with the C/C++ tutorials. We should all make a collective effort to put as many high quality tutorials on the site as possible. Mods probably won't like it much since they'll have to do a ton of reading, but I think it would really add value to the site.

So what does everybody think? Is anyone in? If we can get a few people to dedicate some time to write 2 or 3 tutorials, I think we can make a good jump. If enough people are interested, maybe we can start Sunday.

Is This A Good Question/Topic? 0
  • +

Replies To: Tutorial Week!

#2 pemcconnell  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 54
  • View blog
  • Posts: 472
  • Joined: 05-August 08

Re: Tutorial Week!

Posted 03 October 2008 - 06:43 AM

I'm in :)

I've one tutorial (blackjack game) ready and waiting - going to think up some new ideas and will post em when the week officially kicks off.

This post has been edited by pemcconnell: 03 October 2008 - 07:57 AM

Was This Post Helpful? 0
  • +
  • -

#3 engale  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 3
  • View blog
  • Posts: 594
  • Joined: 30-September 08

Re: Tutorial Week!

Posted 03 October 2008 - 10:44 AM

I'm game too. I'll see what I've already written and if i have time once we start off I'll get them submitted. While on the topic, why not list a few things here that we really wanta see in tutorial form.

Edit:

and on that note I would really like to know how to run a certian php script at certian times or after a certian amout of time is over. IE: have the server do it.

This post has been edited by engale: 03 October 2008 - 10:54 AM

Was This Post Helpful? 0
  • +
  • -

#4 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 43
  • View blog
  • Posts: 903
  • Joined: 08-August 08

Re: Tutorial Week!

Posted 03 October 2008 - 11:11 AM

i could do one about pagination

ill also see if i can do a couple of others
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Tutorial Week!

Posted 03 October 2008 - 11:26 AM

For the record C# is #3, and there wasn't even a C# section when I joined last year, so :P
Was This Post Helpful? 0
  • +
  • -

#6 ghqwerty  Icon User is offline

  • if($spareTime > 0){ $this->writeCode(); }
  • member icon

Reputation: 43
  • View blog
  • Posts: 903
  • Joined: 08-August 08

Re: Tutorial Week!

Posted 03 October 2008 - 11:29 AM

yer but c++ is first :o

is this an ok tutorial ??

	// a table i created to show users 
							// it shows 20 users per page
							//it will show the next 2 and previous 2 pages in the links along with the last page and a next and previous button 
							$max = 20; //amount of users per page. change to what you want
								$users = $_GET['users'];
									if(empty($users))
									{
										$users = 1;
									}
							$limits = ($users - 1) * $max; 
							//view the users
							if(isset($_GET['items']) && $_GET['items'] == "view"){
								$id = $_GET['id'];
								$sql = mysql_query("SELECT * FROM members");
									while($r = mysql_fetch_array($sql)){
										$id = $r['id'];
										$user = $r['username'];
										$rank = $r['rank'];
											echo "<div><p>$id</p><p>$user</p><p>$rank</p></div>";
									}	
							}else{
								//select all the users 
								$sql = mysql_query("SELECT * FROM members LIMIT ".$limits.",$max") or die(mysql_error());
								//count how many users there are 
								$totalres = mysql_result(mysql_query("SELECT COUNT(id) AS tot FROM members"),0);	
								//the total number of pages (calculated result), math stuff...
								$totalpages = ceil($totalres / $max); 
								//starts the table
								//show the titles for each column
									echo "
									<table id='users' height='20%' width='35%' border='1'>
										<tr>
											<td colspan='3'>
												<center>
													users
												</center>
											</td>
										</tr>
										<tr>
											<td width='25%'>
												<center>
													userid
												</center>
											</td>
											<td width='45%' >
												<center>
													username
												</center>
											</td>
											<td width='30%'>
												<center>	
													rank
												</center>
											</td>
										</tr>";
								if($totalres < 1){//if there is no data in the database echo Where'd everyone go !!!
									echo "<tr><td colspan=\"3\"><center>Where'd everyone go !!!</center></td></tr></table>";
									
								}else{
									while($r = mysql_fetch_array($sql)){//show all the records in the database that match the query
										$id = $r['id'];//assigns id from the database to $id
										$user = $r['username'];	//assigns username from the database to $user									
										$rank = $r['rank'];	//assigns rank from the database to $rank		
										//show the data in the correct	column									
										echo "
												<tr>
													<td width='25%'>
														<center>
															".$id."
														</center>
													</td>
													<td width=\"45%\">
														<center>
															".$user."
														</center>
													</td>
													<td width=\"30%\">  
														 <center>
															".$rank."
														</center>  
													</td>
												</tr> ";
									}
									
									$prev_page = $users - 1;
									
									
								echo "<tr><td colspan='3'>";
										
										if($prev_page >= 1){
											echo "<b><< <a href=users.php?users=$prev_page>Prev.</a></b>"; //if you are on page 2 or more display a previous  link
										}
									if($totalpages <= 3){
										//this is the pagination link										 
										for($i = 1; $i <= $totalpages; $i++){ 
											echo "<a href='users.php?users=$i'> $i </a>| ";//if there are less than 3 pages just show 1|2|3
										}

									}else{
										$twobefore = $users-2;
										$onebefore = $users-1;
										$oneafter = $users+1;
										$twoafter = $users+2;
										//i prefer using a nested version as i understand it easuier you could just as easily use an elseif formula
										if($twobefore >= 1){
											echo "<a href=users.php?users=$twobefore> $twobefore </a>";//if you are on page 3 or more show a link to the previous 2 pages
											if($onebefore >= 1){
												echo "<a href=users.php?users=$onebefore> $onebefore </a>";//if you are on page 2 or more show a link to the previous page
												echo "<a href=users.php?users=$user> $user </a>"; // show the link for the page you are currently on 
												if($oneafter <= $totalpages){
													echo "<a href=users.php?users=$oneafter> $oneafter </a>";// if you are more than 1 page off max pages show link to next page
													if($twoafter <= $totalpages){
														echo "<a href=users.php?users=$twoafter> $twoafter </a>";// if you are more than 2 page off max pages show link to the next 2 pages
														if($twoafter < totalpages){
															echo "...<a href=users.php?users=$totalpages> $totalpages </a>";//show a link to the last page
														}
													}
												}
											}
										}
												
										$next_page = $users + 1;
										if($next_page <= $totalpages) {
										   echo"<a href=users.php?users=$next_page><b>Next</b></a> <b>>></b>";//next link										   
										}
								}
								//close up the table	
								echo "</td></tr>";								
								echo "</table>";
								}
								}

Was This Post Helpful? 0
  • +
  • -

#7 engale  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 3
  • View blog
  • Posts: 594
  • Joined: 30-September 08

Re: Tutorial Week!

Posted 03 October 2008 - 12:19 PM

I just added a tutorial for a character check for a string based on a predefined valid character array.
Was This Post Helpful? 0
  • +
  • -

#8 pemcconnell  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 54
  • View blog
  • Posts: 472
  • Joined: 05-August 08

Re: Tutorial Week!

Posted 06 October 2008 - 01:08 AM

Got one tutorial written up yesterday (game tutorial), and started another (using PHP and MySQL efficiently). Will be doing one more, then uploading all three at some stage this week
Was This Post Helpful? 0
  • +
  • -

#9 kummu4help  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 245
  • Joined: 05-August 08

Re: Tutorial Week!

Posted 06 October 2008 - 01:15 AM

waiting a lot pemcconnell.

i know ur tutorials will be as good as your replies to all the posts here in php section

hope u will post them soon matey..
cheers :P
Was This Post Helpful? 0
  • +
  • -

#10 pemcconnell  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 54
  • View blog
  • Posts: 472
  • Joined: 05-August 08

Re: Tutorial Week!

Posted 06 October 2008 - 01:26 AM

Thanks a lot buddy, hope they live up to expectations :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1