Jump to content

Display Image Of A Specific Student


Recommended Posts

Hello there Admins,


I would like to display the image on his/her profile. This is so far the codes i have made. It displays only the outline border of the image but not the student's image itself.

	$session_id = $_SESSION['admin_id'];
	if($session_id == null){
    include 'Connect.php';
    $student_id = htmlentities($_REQUEST['id'], ENT_QUOTES);
    $result = mysql_query("SELECT * FROM student_information where student_id='$_GET[id]'");
    $data = mysql_fetch_array($result);
    $numRows = mysql_numrows($result);
    $i = 0;
    while($i < $numRows)  {
         <img src="display_image.php?id=<?php echo mysql_result($data,$i,"id"); ?>" width="175" height="200" 

Please advise me how to modify these codes to make the image display.


By the way this is the display_image.php i created.

    include 'Connect.php';
 	$flag = "";
    $student_id = htmlentities($_REQUEST['id'], ENT_QUOTES);
if (IsSet($_GET['id'])){
$result = @mysql_query("select * from student_information where student_id = ".$_GET['id']);
header("Content-type: image/jpeg");
header("Pragma: public");
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Cache-Control: private",false);
header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" );
header("Content-Transfer-Encoding: binary");
header("Content-Type: PHP Generated Data");
header("Content-Length: ".filesize($filename));

while ($data = mysql_fetch_array($result))
print $data['LRCard'];}
Edited by phpNOvice
Link to comment
Share on other sites

I have uploaded the specific image of the student in




and i want to display it specifically on their profile given their unique id.


I really think there is something missing in my codes maybe the path but i just dont know how to express it.


Please advise


Note: "images" is a folder where all the image of the students are saved.

Edited by phpNOvice
Link to comment
Share on other sites

As the images are uploaded to the server (I assume using a web interface) you should rename the images (according to the profileID) to avoid name collisions should someone else try to upload an image of the same name. Then you should store that image name in the database where you can use this to build the path to the image in your pages. 


Now, if the  images are renamed to the profileID, then in theory you don't have to store any image reference in the database since you could just use the profileID combined with the image directory to find your images. 


... Depends on the needs of your project.



Link to comment
Share on other sites

  • 2 weeks later...

Hello Admin,


This is my upload code

			if($_FILES['image']['name'] != ""){
				$filename = $_FILES['image']['name'];
				$ext = strrchr($filename,".");
				$imagename = $student_id;
				if($ext ==".jpg" || $ext ==".jpeg" || $ext ==".JPG" || $ext ==".JPEG" || $ext ==".gif" || $ext ==".GIF"){
					$size = $_FILES['image']['size'];
					if($size > 0 && $size < 5000000){
						$archive_dir = "images";
						$userfile_tmp_name = $_FILES['image']['tmp_name'];
						if(move_uploaded_file($userfile_tmp_name, "$archive_dir/$imagename"))

and the image is successfully uploaded to






 you should rename the images (according to the profileID) 

with the student id (not the unique number) is the file name.


The same codes for display_image.php and the student_view.php as shown above.

But still no luck the image still broken.


Please advise.

Edited by phpNOvice
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...