Page 1 of 1

Help with Id=View

Posted: Sun Apr 08, 2012 2:41 pm
by Ellie123
So i have a members list,

http://sketchedneo.com/testmemberlist.php


I want to make the names clickable so people can view the members profiles.

But Ive gone around in cirlces for 3 days now.

Can someone help please.

Code: Select all

<?php



$pagetitle = "All Users";

$checkrank = 5;


include ($_SERVER['DOCUMENT_ROOT'].'/header.inc.php');

$min=$_GET['min'];

$num = mysql_num_rows(mysql_query("SELECT id FROM members"));


echo "<center>Lutari has $num members.<p><table width=\"226\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" style=\"border-top: 1pt solid black;border-bottom: 1pt solid black;border-left: 1pt solid black;border-right: 1pt solid black; \">
  <tr>
    <td width=\"100\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#5eaed4;\">Username</td>
    <td width=\"100\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#5eaed4;\">Joined</td>
   <td width=\"100\" style=\"border-bottom: 1pt solid black; background-color:#5eaed4;\">Rank</td>

  </tr>";


if ($num <= 0)
{
	echo "

<tr>
    <td colspan=\"4\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#f4f4f4;\" ><center>There are no muted users :D</center></td>
  </tr>";
}


if (!$min) { $min = 0; }
$max = $min + 50;
$sort = mysql_query("SELECT * FROM members ORDER BY username LIMIT $min,50");
while($sort2 = mysql_fetch_array($sort))


{
if (!$min) { $min = 0; }
$max = $min + 50;


{



$x = 0;





if ($num >= 1)

$datejoin = date("M j Y",$sort2[joined]); 
$rankk = mysql_fetch_array(mysql_query("SELECT * FROM jobs WHERE id = '$sort2[rank]'"));
echo "<center>\n";

 if($sort2[id]){

echo("

 <tr>
    <td style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#f4f4f4;\" valign=\"top\">$sort2[username]</td>
    <td style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#f4f4f4;\" valign=\"top\">$datejoin</td>
    <td style=\"border-bottom: 1pt solid black; background-color:#f4f4f4;\" valign=\"top\">$rankk[job]</td>
  </tr>

"); }





}

}





echo "<tr>
  <td colspan=\"4\" style=\"background-color:#5eaed4;\" >&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>";



if ($num >= 50)
{
echo "<p align=center><a href=$baseurl/staff/all_members.php?min=$max><b>Next page</b></a></p>";
}
if ($min != 0)
{
	$prev_min = $min - 50;
	echo "<p align=center><a href=$baseurl/staff/all_members.php?min=$prev_min><b>Previous page</b></a></p>";
}




$x = 0;







echo "<p></center>\n";

	
echo "</center>\n";





include ($_SERVER['DOCUMENT_ROOT'].'/footer.inc.php');


?>



I also want to code it onto my forum to make their names click to their profiles too.

http://www.sketchedneo.com//forum/forum.php



Code: Select all

<?php



$pagetitle = "Forum";

$checkrank = 2;


include ($_SERVER['DOCUMENT_ROOT'].'/header.inc.php');
include ($_SERVER['DOCUMENT_ROOT'].'/security/smiliesonly.php');
$min=$_GET['min'];
$id=$_GET['id'];

$sort00 = mysql_fetch_array(mysql_query("SELECT * FROM forum_boards WHERE id = '$id'"));
$file = "staff";
if ($sort00[filed] == $file AND $rank < 5)
{
	 die("<center>You can not view this board.");
}



$num = mysql_num_rows(mysql_query("SELECT id FROM forum_topic WHERE board = '$id'"));

echo "<center><a href=\"$baseurl/forum/forum.php\">Boards</a> || <a href=\"$baseurl/forum/add_topic.php\">Add Topic</a> || <a href=\"$baseurl/forum/preferences.php\">Preferences</a><p></center>";


echo "<center><table width=\"635\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" style=\"border-top: 1pt solid black;border-bottom: 1pt solid black;border-left: 1pt solid black;border-right: 1pt solid black; \">
  <tr>
 <td width=\"108\" valign=\"middle\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#5eaed4;\"><center>
 Posted By
 </center></td>
    <td width=\"424\" valign=\"middle\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#5eaed4;\"><center>Title</center></td>
    <td width=\"77\" valign=\"middle\" style=\"border-bottom: 1pt solid black; background-color:#5eaed4;\"><center>
      Last Post
    </center></td>
  </tr>";


if ($num <= 0)
{
	echo "

<tr>
    <td colspan=\"4\" style=\"border-bottom: 1pt solid black; background-color:#f4f4f4;\" ><center>There are no topics on this board :(</center></td>
  </tr>";
}


if (!$min) { $min = 0; }
$max = $min + 30;
$sort = mysql_query("SELECT * FROM forum_topic WHERE board = '$id' ORDER BY updated DESC LIMIT $min,30");
while($sort2 = mysql_fetch_array($sort))


{
if (!$min) { $min = 0; }
$max = $min + 30;


{



$x = 0;





if ($num >= 1)



echo "<center>\n";

 if($sort2[id])

{

$numreplies = mysql_num_rows(mysql_query("SELECT * FROM forum_replies WHERE topic = '$sort2[id]'"));
$sort4 = mysql_fetch_array(mysql_query("SELECT * FROM forum_replies WHERE topic = '$sort2[id]'"));

$ftime = date("H:i",$sort2[date]); 
$fdate = date("M j Y",$sort2[date]); 
$updated = date("M j Y",$sort2[updated]); 
$ftitle = smiliesonly($sort2[title]); 

echo("

    <tr>
    <td width=\"108\" valign=\"middle\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#f4f4f4;\"><center>
      <p>$sort2[postedby]<br>
          $fdate $ftime</p>
    </center></td>
    <td width=\"424\" valign=\"middle\" style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#f4f4f4;\"><a href=\"$baseurl/forum/topic.php?id=$sort2[id]\">$ftitle</a></td>
    <td width=\"77\" valign=\"middle\" style=\"border-bottom: 1pt solid black; background-color:#f4f4f4;\"><center>
     $updated<br> 
     Replies: $numreplies
    </center></td>
  </tr>
  

"); }





}

}





echo "<tr>
  <td colspan=\"3\" style=\"background-color:#5eaed4;\" >&nbsp;</td>
</tr>
</table>
<p>&nbsp;</p>

";



if ($num >= 30)
{
echo "<p align=center><a href=$baseurl/forum/board.php?min=$max><b>Next page</b></a></p>";
}
if ($min != 0)
{
	$prev_min = $min - 30;
	echo "<p align=center><a href=$baseurl/forum/board.php?min=$prev_min><b>Previous page</b></a></p>";
}



$x = 0;









echo "<p></center>\n";

	
echo "</center>\n";





include ($_SERVER['DOCUMENT_ROOT'].'/footer.inc.php');


?>


Also, The warnings you get at the top of pages, are not there when logged in.


Thank you

Re: Help with Id=View

Posted: Sun Apr 08, 2012 4:18 pm
by social_experiment
Ellie123 wrote:I want to make the names clickable so people can view the members profiles.
A quick glance at your doesn't show any code that would do what you have in mind (unless the line below is the 'link' to show a users' profile)

Code: Select all

<?php <td style=\"border-bottom: 1pt solid black;border-right: 1pt solid black; background-color:#f4f4f4;\" valign=\"top\">$sort2[username]</td> ?>
The basic idea behind what you want to achieve is to get something from the database that is unique to each user and use this as a reference when selecting information from the db. I often use an auto-incrementing primary key for this purpose. This value is placed inside a hyperlink (page.php?id=3) and accessed by $_GET['id']. When you click the link you will select all information that you want to use that has the id of 3 inside the database.

Re: Help with Id=View

Posted: Sun Apr 08, 2012 4:22 pm
by califdon
It is quite difficult to read through your script due to the amount of blank lines and the absence of indentation of code blocks. In general, though, I can think of various ways that a user's profile might be stored, and the process of displaying the profiles depends on what is stored and how it is stored (is it in the same table that you are going through or a different one? Does it contain images? etc.). Then how will you want to display the profile? A separate page? A pop-up? A display on the same page without closing the main page? The general approach is that you have to send the data necessary to display the profile of each member as part of the item you are displaying in the list. So it could be a hyperlink ("anchor" tag) or it could be a call to a Javascript function that uses AJAX to return to the server for more data, etc.

Re: Help with Id=View

Posted: Mon Apr 09, 2012 6:27 am
by Ellie123
The idea is, so when you click a members name, then a new page loads which is to be their profile.

Like is does on this forum/Facebook

Im still learning PHP, So please bare with me.

If you look at this page http://www.sketchedneo.com//staff.php you can see the "staff" profile layout, However I want all user Profiles to show when yo click their name on the forum, So each user has their own profile page, Make sense?

Re: Help with Id=View

Posted: Mon Apr 09, 2012 7:06 am
by Ellie123
The easiest way to describe it.

I have a forum, Which members have to register to use.
However I want the forum to link to member's profiles, Like it does here.

My database is all set up for this as far as I can see.

Also I am yet to make the design for the profile pages, Shall i do this now?




Using an auto-incrementing primary key, How do I do this?

My Members database is laid out like:


username varchar(200) latin1_swedish_ci No 0
password varchar(216) latin1_swedish_ci No 0
security varchar(200) latin1_swedish_ci No
email varchar(216) latin1_swedish_ci No 0
ip varchar(200) latin1_swedish_ci No
rank varchar(216) latin1_swedish_ci No 0
name varchar(30) latin1_swedish_ci No
age varchar(40) latin1_swedish_ci No New Born :3
gender varchar(40) latin1_swedish_ci No
location varchar(40) latin1_swedish_ci No
helpfaerie int(11) No 1
profile text latin1_swedish_ci No
about text latin1_swedish_ci No
tasks text latin1_swedish_ci No
joined varchar(216) latin1_swedish_ci No 0
laston int(200) No 0
icedmutereason text latin1_swedish_ci No
icedmutedetails text latin1_swedish_ci No
icedmuteby varchar(200) latin1_swedish_ci No 0
icedmutedate int(200) No 0
posts int(11) No 0
signature varchar(216) latin1_swedish_ci No 0
avatar varchar(216) latin1_swedish_ci No 0
neohtml text latin1_swedish_ci No
siggy text latin1_swedish_ci No
verify int(11) No 0
dpass int(1) No 0

Re: Help with Id=View

Posted: Mon Apr 09, 2012 7:24 am
by social_experiment
Ellie123 wrote:The idea is, so when you click a members name, then a new page loads which is to be their profile.
This line describes quite adequately what you have in mind;
Ellie123 wrote:Like is does on this forum/Facebook
The PHPDN forum uses a similar method to what i describe; for example your profile can be accessed by clicking on this link memberlist.php?mode=viewprofile&u=367029
The 'mode' option contains 'viewprofile' describing what to do and 'u' contains a value unique to your record in the database.
Ellie123 wrote:Also I am yet to make the design for the profile pages, Shall i do this now?
A full working page isn't necessary at this stage imo, first get the code that will retrieve data for each user working; then you can style / design the page.

If you want a php server side method, no javascript, then this method will work for you

Re: Help with Id=View

Posted: Mon Apr 09, 2012 7:26 am
by Celauran
So you have a link to, say, profile.php?id=27

In your profile.php you look for $_GET['id'] and use that to pull the right user from the database. Where are you running into trouble?

Re: Help with Id=View

Posted: Mon Apr 09, 2012 10:23 am
by Ellie123
Im stuck,

What code and where do i place it, So it shows up on the forum?

right now the forum shows who posted what, but isnt a link.

Re: Help with Id=View

Posted: Mon Apr 09, 2012 11:36 am
by califdon
Just so we understand, how much experience do you have with writing PHP scripts and HTML? Did you write the scripts that you showed us, or is this a package that you acquired from somewhere else? We will try to help you, but if you have absolutely no experience with writing PHP, it is going to be rather difficult.