Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 136,578 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,958 people online right now. Registration is fast and FREE... Join Now!




Tutorial Week!

 
Reply to this topicStart new topic

Tutorial Week!

akozlik
3 Oct, 2008 - 05:40 AM
Post #1

D.I.C Addict
Group Icon

Joined: 25 Feb, 2008
Posts: 614



Thanked: 24 times
Dream Kudos: 750
My Contributions
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.
User is offlineProfile CardPM
+Quote Post

pemcconnell
RE: Tutorial Week!
3 Oct, 2008 - 05:43 AM
Post #2

D.I.C Regular
Group Icon

Joined: 5 Aug, 2008
Posts: 396



Thanked: 37 times
Dream Kudos: 75
My Contributions
I'm in smile.gif

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: 3 Oct, 2008 - 06:57 AM
User is offlineProfile CardPM
+Quote Post

engale
RE: Tutorial Week!
3 Oct, 2008 - 09:44 AM
Post #3

D.I.C Addict
Group Icon

Joined: 30 Sep, 2008
Posts: 549



Thanked: 2 times
Dream Kudos: 50
My Contributions
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: 3 Oct, 2008 - 09:54 AM
User is offlineProfile CardPM
+Quote Post

ghqwerty
RE: Tutorial Week!
3 Oct, 2008 - 10:11 AM
Post #4

D.I.C Regular
Group Icon

Joined: 8 Aug, 2008
Posts: 341



Thanked: 8 times
Dream Kudos: 25
My Contributions
i could do one about pagination

ill also see if i can do a couple of others
User is offlineProfile CardPM
+Quote Post

PsychoCoder
RE: Tutorial Week!
3 Oct, 2008 - 10:26 AM
Post #5

using DIC.Core;
Group Icon

Joined: 26 Jul, 2007
Posts: 8,997



Thanked: 125 times
Dream Kudos: 8625
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net

My Contributions
For the record C# is #3, and there wasn't even a C# section when I joined last year, so tongue.gif
User is offlineProfile CardPM
+Quote Post

ghqwerty
RE: Tutorial Week!
3 Oct, 2008 - 10:29 AM
Post #6

D.I.C Regular
Group Icon

Joined: 8 Aug, 2008
Posts: 341



Thanked: 8 times
Dream Kudos: 25
My Contributions
yer but c++ is first ohmy.gif

is this an ok tutorial ??

CODE
    // 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>";
                                }
                                }

User is offlineProfile CardPM
+Quote Post

engale
RE: Tutorial Week!
3 Oct, 2008 - 11:19 AM
Post #7

D.I.C Addict
Group Icon

Joined: 30 Sep, 2008
Posts: 549



Thanked: 2 times
Dream Kudos: 50
My Contributions
I just added a tutorial for a character check for a string based on a predefined valid character array.
User is offlineProfile CardPM
+Quote Post

pemcconnell
RE: Tutorial Week!
6 Oct, 2008 - 12:08 AM
Post #8

D.I.C Regular
Group Icon

Joined: 5 Aug, 2008
Posts: 396



Thanked: 37 times
Dream Kudos: 75
My Contributions
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
User is offlineProfile CardPM
+Quote Post

kummu4help
RE: Tutorial Week!
6 Oct, 2008 - 12:15 AM
Post #9

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 174


Dream Kudos: 25
My Contributions
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 tongue.gif
User is offlineProfile CardPM
+Quote Post

pemcconnell
RE: Tutorial Week!
6 Oct, 2008 - 12:26 AM
Post #10

D.I.C Regular
Group Icon

Joined: 5 Aug, 2008
Posts: 396



Thanked: 37 times
Dream Kudos: 75
My Contributions
Thanks a lot buddy, hope they live up to expectations smile.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:21AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month