#1
|
||||
|
||||
PHP/MySQL Tutorial
Im just making this as a resource for people who do not know how to/can't remember how to make a loop for mysql data in PHP
READ THIS FIRST: Kae's Mysql and PHP Basics This thread will show you how to utilize the while function in php loops to help with outputting mysql data. 1. How to setup the while loop for data processing PHP Code:
To get mysql data into a variable, it's basically the same as putting a number in a variable PHP Code:
PHP Code:
Let's pretend we have 2 columns in our table
A nifty little function we will be using is called mysql_result() Heres basically how it works PHP Code:
Also, before i forget If you don't already know, there is a nice shortcut for upping your $vars by 1, its $var++; Now let's start the actual coding First Let's get our data from our table and initiate the while loop PHP Code:
PHP Code:
Now we get the second row: PHP Code:
Now we use a simple method to echo the results onto the page PHP Code:
Code:
Hello, my name is Glenn of the Quagmire family. Hello, my name is Peter of the Griffin family. Hello, my name is Joe of the Swanson family. Hello, my name is Cleveland of the Brown family. Hello, my name is Robo of the Chicken family. I hope this helped
__________________
dasheep.tk |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Gradient Map Tutorial | Whimsy | Art Gallery | 0 | 10-20-2014 04:55 PM |
OOP Tutorial request | Ruinily | Suggestions and Feature Requests | 4 | 02-09-2013 01:42 PM |
Basic PHP & MySQL Tutorial | Kaeliah | Tutorials and Tips | 8 | 03-23-2011 07:50 PM |
Intermediate PHP & MySQL Tutorial I | Kaeliah | Tutorials and Tips | 4 | 01-31-2011 04:20 PM |
Quick php tutorial | Ajof | Tutorials and Tips | 18 | 11-08-2010 12:20 PM |
What's New? |
What's Hot? |
What's Popular? |