garydt Posted March 26, 2007 Share Posted March 26, 2007 I'm making a website where registered users can upload a photo as well as information. The main page will display all of the users' photos. When user1 clicks on, say, user5's photo i want a page to open up and user5's information. How do i do this? Every user has a username stored in the database along with their information and the url to their photo. Code of the main page- <?php require_once('Connections/elvisdb.php'); ?> <?php if (!function_exists("GetSQLValueString")) { function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } } ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> <style type="text/css"> <!-- .style1 {color: #FFFFFF} .style3 {color: #000099} --> </style> </head> <body> <table width="1100" border="0" cellpadding="5"> <tr> <td width="151"><table width="150" bgcolor="#F48D02" border="0" cellpadding="0"> <tr> <td class="style3"> </td> </tr> </table></td> <?php mysql_select_db($database_elvisdb, $elvisdb); $query_Recordset1 = "SELECT * FROM images ORDER BY `count` DESC"; $Recordset1 = mysql_query($query_Recordset1, $elvisdb) or die(mysql_error()); while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)) { for ($i=1;$i<=3;$i++) { $totalRows_Recordset1 = mysql_num_rows($Recordset1); echo $i; ?> <td> <p><img src="<?php print $row_Recordset1['imageName']?>"></p> <p><?php print $row_Recordset1['usnm']?></p> </td> <?php if ($i=3) { ?> <br /> <?php } } } ?> </tr> </table> </body> </html> <?php mysql_free_result($Recordset1); ?> The username is stored in the 'usnm' field. Link to comment https://forums.phpfreaks.com/topic/44398-opening-a-page-to-display-the-right-info/ Share on other sites More sharing options...
AndyB Posted March 31, 2007 Share Posted March 31, 2007 First get the username as a link (althought the record ID might make more sense) <p><?php echo "<a href='show_user.php?user=". $row_Recordset1['usnm']. "'>". $row_Recordset1['usnm']. "</a>";?></p> Then create new file show_user.php. Retrieve the value of usnm from the $_GET array and use that to search and retrieve data for that user. Link to comment https://forums.phpfreaks.com/topic/44398-opening-a-page-to-display-the-right-info/#findComment-218485 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.