Unstoppable Domains

URGENT Php help needed.

Spaceship Spaceship
Watch

electricbeat

Account Closed
Impact
0
So, I have browse.php or /page-browse/ using mod_rewrite. You can view the file here: http://ryan.xenka.com - now. If you click R, it shows all the users that begin with R but it still has go to page 2, now if you go to page 2 it shows users that don't have a name that begin with R, basically I need help on getting this working so if I do show page R it doesnt say go to page 2 and then show users with another name.

This is my code:

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<meta http-equiv="content-type" content="text/html;charset=iso-8859-2" />

<link rel="stylesheet" href="images/style.css" type="text/css" />

<title>MusicInterests</title>

</head>

<body>

	<div class="content">

		<div class="header_right">

			<div class="top_info">

				<div class="top_info_right">

					<p><?php include("logged.php"); ?></p>					

				</div>		

			</div>

					

			<div class="bar">

				<ul>

					<li class="slogan">Navigation:</li>

<?php include("navigation.php"); ?>

				

				</ul>

			</div>

		</div>

			

		<div class="logo">

			<h1><a href="#" title="The best music on the net!">Music <span class="red">Interests</span></a></h1>

			<p>What are you listening too?</p>

		</div>

		

		<div class="search_field">

			<?php include("searchform.php"); ?>

		</div>

		

		<div class="newsletter">

			<p>Subscribe for the Newsletter!</p>

		</div>

		

		<div class="subheader">

			<p><?php include("top.php"); ?></p>

		</div>

		

		<div class="left">

			<div class="left_articles">

				<h2>Browse</h2>

				<p><?php

ob_start();

include("config.php");

if (!$_GET[user]){

if(!isset($_GET['page'])){

$page = 1;

} else {

$page = $_GET['page'];

}

$max_results = "20"; // Change to how many member you would like to display per page

$start_var = $_GET['start'];

$start_var = substr($start_var,0,1);

if(preg_match("([a-zA-Z])",$start_var))

{

$where_clause = "where username like '$start_var" . "%" . "'";

}

else

$where_clause = ""; 

$from = (($page * $max_results) - $max_results);

 $getuser = mysql_query("SELECT * FROM users $where_clause ORDER BY username ASC LIMIT $from, $max_results");

while ($user = mysql_fetch_array($getuser)){

// gets all the users information.

echo ("<a href=\"/user-$user[username]\">$user[username]</a><br />\n");

// links to a page to view the user's profile.

}

echo "Go to page: ";

$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM users"),0);

$total_pages = ceil($total_results / $max_results);

for($i = 1; $i <= $total_pages; $i++){

if(($page) == $i){

echo "$i ";

} else {

echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i\" title=\"Go to page $i\">$i</a> ";

}

}

} else {

$getuser = mysql_query("SELECT * FROM users WHERE username = '$_GET[user]'");

$usernum = mysql_num_rows($getuser);

if ($usernum == 0){

echo ("User Not Found");

} else {

mysql_query("update users set views=views+1 where username='$_GET[user]'") or die(mysql_error());

$views = mysql_query("select * from users where username='$_GET[user]'") or die(mysql_error());

$resviews = @mysql_fetch_array($views);

$profile = mysql_fetch_array($getuser);

echo ("Username: <i>$profile[username]</i><br />

Location: <i>$profile[location]</i><br />

Email: <i>$profile[email]</i><br>

Profile hits: <i>$resviews[views]</i><br><br />



<b>Music Interests</b><br />

1. $profile[artist1] - <i>$profile[song1]</i><br />

2. $profile[artist2] - <i>$profile[song2]</i><br />

3. $profile[artist3] - <i>$profile[song3]</i><br />

4. $profile[artist4] - <i>$profile[song4]</i><br />

5. $profile[artist5] - <i>$profile[song5]</i><br />

6. $profile[artist6] - <i>$profile[song6]</i><br />

7. $profile[artist7] - <i>$profile[song7]</i><br />

8. $profile[artist8] - <i>$profile[song8]</i><br />

9. $profile[artist9] - <i>$profile[song9]</i><br />

10. $profile[artist10] - <i>$profile[song10]</i><br />

");

// in the above code, we display the user's information.

}

}

?><br /><br />Looking for a specific username?<br /><a href="page-browse">All</a> - 

<a href="browse-A">A</a> - <a href="browse-B">B</a> - <a href="browse-C">C</a> - <a href="browse-D">D</a> - <a href="browse-E">E</a> - <a href="browse-F">F</a> - <a href="browse-G">G</a> - <a href="browse-H">H</a> - <a href="browse-I">I</a> - <a href="browse-J">J</a> - <a href="browse-K">K</a> - <a href="browse-L">L</a> - <a href="browse-M">M</a> - <a href="browse-N">N</a> - <a href="browse-O">O</a> - <a href="browse-P">P</a> - <a href="browse-Q">Q</a> - <a href="browse-R">R</a> - <a href="browse-S">S</a> - <a href="browse-T">T</a> - <a href="browse-U">U</a> - <a href="browse-V">V</a> - <a href="browse-W">W</a> - <a href="browse-X">X</a> - <a href="browse-Y">Y</a> - <a href="browse-Z">Z</a>

</p>

			</div>

		</div>	

		<div class="right">

						

			<div class="rt"></div>

			<div class="right_articles">

				<p><b>Most viewed</b><br />The most viewed tool allows you too find the 30 most viewed profiles on musicinterests!</p>

			</div>

			<div class="rt"></div>

			<div class="right_articles">

				<p><b>Links</b><br />

				<?php include("links.php"); ?></p>

			</div>

			<div class="rt"></div>

			<div class="right_articles">

				<p><?php include("sponsor.php"); ?></p>

			</div>

		</div>	

		<div class="footer">

			<p><?php include("footer.php"); ?></p>

		</div>

	</div>

</body>

</html>
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Quickly browsing your code, your problem is getting the page numbers. Your query is:

Code:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM users"),0);

You're just grabbing the total number of records in your users table here, not the total number of records that start with a selected letter. Try altering your query to the following:

Code:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM users $where_clause"),0);

Including the where clause will ensure you're checking specific letters if requested.

Also note, instead of hardcoding each link to each letter, you can use a simple array of letters and a for loop:

Code:
$letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
echo '<a href="/page-browse">All</a>ย ';
for($i=0; $i < strlen($letters); $i++) {
    echo '<a href="/browse-'.$letters[$i].'">'.$letters[$i].'</a>ย ';
}

:)
 
0
•••
That works, thank you very much CreedFeed, I have almost finished the frontend of my site.
 
0
•••
Appraise.net
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back