Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
2.00/5 (4 votes)
See more:
I am developing a Website Where I need to register users, for that I develop a simple HTML Form and use PHP to send data in MYSQL Database, its working perfectly.

But now I need display those profiles[stored in MYSQL Database] one after another
e.g.
Photo                 Profile ID : 1
                      Name : MR. Abc XYz
                      Address : fghgf
                      Qualification: gjhgf


PHOTO                Profile ID :2
                     Name:  mno  pqo
                     :
                     :

PHOTO                Profile ID :3
                     Name:  bbbb hhhh
                     :
                     :

One page will contain 6-7 profile and then next 6-7 to 2nd page and so on.

This is my problem.
I know its not possible to provide Code for this problem in CodeProject, but please some knowledge or some Links will be help full for me.
Please share your valuable knowledge and please help me.
Posted
Updated 3-Sep-12 21:21pm
v2
Comments
[no name] 3-Sep-12 14:32pm    
1 down rating 1 up rating.
please don't rate
please answer or comment for any clarification
Mohibur Rashid 3-Sep-12 20:43pm    
I wont rate. But I will give you a link.
www.google.com
Mohibur Rashid 4-Sep-12 4:40am    
The point is not informing you about google. it was reminding you about searching online. Most people make a common mistake. if you search your problem you will get solution in 99.99% (its not literal) cases. break down your problems into small pieces and then search online. that was my point.
[no name] 4-Sep-12 5:42am    
you are a Genius, to solve your problem through google.
great man.
why you are wasting your time in codeproject then.
go and join google.
enhzflep 4-Sep-12 7:32am    
Now, now - there's no need to make a sunshine of yourself.
Mohibur's tongue-in-cheek suggestion is perfectly valid. It is unfortunate that his point appears too complex and has been lost on you.

The fact that you see an insult as a fit response to his suggestions further underscore the point.

I suggest you read a copy of Dale Carnegie's book. ;)

1 solution

As per the comments I added earlier, there's a number of things to keep in mind here.

You need to know:
(1) Which 'page' you'd like to display
(2) How many results you'd like to display on each page.

I've chosen to display the information for each user in a single-row html table. The first cell contains an image, while the second cell contains text information.

I've used single quotes - ' wherever the string doesn't need interpreting. I've used double-quotes " whenever the string contains a php variable that should be substitued by it's value. (It's faster to use single quotes, more functional to use double quotes) - You should consider the code that outputs the image as being wrapped in double-quotes. In this case the string contains an interpreted value inside of single quotes. This will equate to single quotes wrapped around some text value.

PHP
$sql = "select some stuff limit $firstEntryToShow $lastEntryToShow";
$result = mysql_query($sql);
while ($row = mysql_fetch_row($result))
{
    $photoSrc = $row[0];
    $profileId = $row[1];
    $name = $row[2];
    $address = $row[3];
    $qualif = $row[4];

    echo '<table>';
    echo '<tbody>';
    echo "<tr>";
    echo "<td><img src='$photoSrc'/></td>";
    echo "<td>Profile ID: $profileId<br>Name: $name<br>Address: $address<br>Qualification: $qualif</td>";
    echo '</tr>';
    echo '</tbody>';
    echo '</table>';
}


You can set the $firstEntryToShow by taking a variable that specifies which page you'd like to view, and multiplying that value with the number of records your'd like to display on each page. You can then calculate $lastEntryToShow by adding $numEntriesPerPage-1 to $firstEntryToShow.

Note: the code below assumes that the url contains a variable named pgnum
E.g: http://www.somehost.com/someFile.php?pgnum=1
PHP
$pageNumber = $_GET['pgnum'];
$numEntriesPerPage = 7;
$firstEntryToShow = $pageNumber * $numEntriesPerPage;
$lastEntryToShow = $firstEntryToShow + ($numEntriesPerPage-1);

You can use isset to see if the variable has been given.
e.g:
PHP
if (isset($_GET['pgnum']))
   $pageNum = $_GET['pgnum'];
else
   $pageNum = 0;
 
Share this answer
 
v2
Comments
[no name] 4-Sep-12 7:18am    
Ok!
Thanks
Don't delete the comments part, its neccessary for me to build my project.
Thanks a lot.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900