Not logged in

Your Account

Dynamic Profiles

Home/Tutorials/Dynamic Profiles

Dynamic Profiles

Content by: Steve Stewart

Posted a year ago with 847 views

Dynamic DJ/Presenter Profiles

Firstly you need a table in your database, for this tutorial our database is called djprofiles.
In the structure of our database: djid, name, bio, imgpath
Creating the table:

CREATE TABLE `djprofiles` (`djid` int(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, `name` varchar(255) NOT NULL, `bio` text NOT NULL, `imgpath` varchar(255) NOT NULL)

A row in the database with a DJ is like this:
1 - SteveAlmighty - The one who you listen to when you're bored - djpics/stevespic.jpg

With the profile page we need to GET the djid and move onto asking the database for the information...
So below we are using php to:

FROM `djprofiles` (The database table)
WHERE `djid`='$djid' (The DJID is equal to the profile id we get (profile.php?djid=1))
LIMIT 1 as we only want 1 return that matches.

From here we are getting all the information and put into variables so we can display what and where we need to using echo.


$djid = preg_replace('#[^0-9]#i', '', $_GET['djid']);
settype($djid, 'integer');

$sqldj = mysqli_query($db_conx, "SELECT * FROM `djprofiles` WHERE `djid`='$djid' LIMIT 1");
while($row = mysqli_fetch_array($sqldj)){
	$djname = $row["name"];
	$djbio = $row["bio"];
	$djimg = $row["imgpath"];
<title><?php echo $djname; ?></title>

<h1><?php echo $djname; ?>'s Profile</h1>
<p><?php echo $djbio; ?></p>
<img src="<?php echo $djimg; ?>" style="min-height:220px;max-height:240px;" />

Save the script as "profile.php"
Then goto profile.php?djid=1
The more DJs/Presenters you have you just change the ending number.
Visit XperienceRadio DJs to see how it works, notice in the address bar when you view a profile.

You can see the same principles are applied throughout and not just for profiles, take these tutorials for eg, noticed the address bar: tutorials-php-view.php?id=6