/    Sign up×
Community /Pin to ProfileBookmark

Quest on search script that shows user info with his/her photo

Hello guys, I am familiar with search scripts(base on his/her user i.d, name, etc) that will show user informations like name, lastname, age etc. But I have no idea on how to also display a user photo together with his/her information. I heard that storing image (blob type) on mysql is not a good idea. Does anybody here have an idea on how to do it with php file handlings? Also, when that image(user photo) together with user information have been shown, that page also includes a link in which you can click it to download a document ( user word docs). Thanks.

to post a comment
PHP

12 Comments(s)

Copy linkTweet thisAlerts:
@tirnaMay 28.2010 — One way to do it is:

1) store the image files in a designated folder somewhere.

2) store the path name of the user's image in the database

3) extract the path name from the database and use it as the .src value in the <img> element when displayinmg the user's photo.

4) you could also wrap the <img> in a <a> that links to the appropriate user document.
Copy linkTweet thisAlerts:
@Jarrod1937May 28.2010 — Is there a reason you can't simply store the unique name of the profile image in the db table? You don't have to store the binary info, just the name of the image so it can be loaded from a location on the file system.
Copy linkTweet thisAlerts:
@anishgiriauthorMay 28.2010 — Is there a reason you can't simply store the unique name of the profile image in the db table? You don't have to store the binary info, just the name of the image so it can be loaded from a location on the file system.[/QUOTE]

There's no reason. Thanks for answer guys, it helps me a lot.
Copy linkTweet thisAlerts:
@anishgiriauthorMay 31.2010 — I have a problem. In the code below how can I assign the value of $_POST['name'] to the variable $pangalan(with out clicking the submit botton), so it will display the data from the table based on the value of $pangalan, even if I did not click the submit botton? How can I also assigned value on that input box in which when the page opened it already has a value that will be automaticaly pass to $_POST['name'] , even without clicking the submit bottom?

I am trying but I can't figure it out.




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Search Contacts</title>

<style type="text/css" media="screen">

ul li{

list-style-type:none;

}

</style>

</head>

<body>

<h3>Search Contacts Details</h3>

<p>You may search either by first or last name</p>

<form method="post" action="search_display2.php?go" id="searchform">

<input type="text" name="name" >

<input type="submit" name="submit" value="Search">

</form>

<?php

$pangalan=$_POST['name'];


//connect to the database

$db=mysql_connect ("localhost", "root") or die ('I cannot connect to the database because: ' . mysql_error());

//-select the database to use

$mydb=mysql_select_db("records2");

//-query the database table

//$sql="SELECT id, fname, lname FROM table1 WHERE fname LIKE '&#37;" . $name . "%' OR lname LIKE '%" . $name ."%'";

$sql="SELECT * FROM table1 WHERE fname LIKE '%" . $pangalan . "%' OR lname LIKE '%" . $pangalan ."%'";

//-run the query against the mysql query function

$result=mysql_query($sql);

//-create while loop and loop through result set

while($row=mysql_fetch_array($result)){

$FirstName =$row['fname'];
$LastName=$row['lname'];
$PhoneNumber=$row['phone'];
$Email=$row['email'];
$image=$row['imagepath'];


//-display the result of the array

echo "<ul>n";

echo "<li>Name: &nbsp;" . $FirstName . " " . $LastName . "</li>n";

echo "<li>" . $PhoneNumber . "</li>n";

echo "<li>" . "<a href=mailto:" . $Email . ">" . $Email . "</a></li>n";

echo "</ul>";

echo "<tr>";

echo "<td><img src ="" . $row['imagepath'].""></td>";


echo "</tr>";

echo '<td><a href="edit(for_search).php?id=' . $row['id'] . '">Edit</a></td>';

}

?>

</body>

</html>
Copy linkTweet thisAlerts:
@tirnaMay 31.2010 — One way is to use AJAX to send the value of 'name' to a php script that gets the info from the database for that name and returns it to the browser to display on the page.
Copy linkTweet thisAlerts:
@anishgiriauthorMay 31.2010 — Thanks for the answer, but what I mean is when a page open it will display data from the table based on the value of $_POST['name'] (it already has a value assigned, even if the submit botton is not yet click).
Copy linkTweet thisAlerts:
@tirnaMay 31.2010 — you can check if $_POST['name'] exists and has a valid value on page load and then do your processing on it.
Copy linkTweet thisAlerts:
@anishgiriauthorMay 31.2010 — I think $_POST ['name'] exist cause I have this on the code <input type="text" name="name" >. Am I right? Sorry, I am just new to PHP, but how can I assign a value on page load? I want the value of the input box in the form to be automaticaly assigned on $_POST ['name'], which means it has a value, even if the submit botton is not click. Thanks.
Copy linkTweet thisAlerts:
@tirnaMay 31.2010 — 
Hello guys, I am familiar with search scripts(base on his/her user i.d, name, etc) that will show user informations like name, lastname, age etc.
[/QUOTE]


In your 1st post above, you said you are familiar with search scripts so I don't see why this is so difficult ?

You simply use isset() to check if $_POST ['name'] exists on page load.
Copy linkTweet thisAlerts:
@anishgiriauthorMay 31.2010 — In your 1st post above, you said you are familiar with search scripts so I don't see why this is so difficult ?

You simply use isset() to check if $_POST ['name'] exists on page load.[/QUOTE]


Sorry, I guess I am not familiar after all. It will exist of course if the $_POST ['name'] has a value, my question is how can I assign a value to that $_POST ['name'] (on page load) ,which means I did not click the submit botton.

What I want is the value of the input box in the form to be automaticaly assigned on $_POST ['name'], which means it already has a value, even if the submit botton is not yet click.
Copy linkTweet thisAlerts:
@tirnaMay 31.2010 — Sorry, I guess I am not familiar after all. It will exist of course if the $_POST ['name'] has a value,.....[/quote]

It could potentially exist even if it doesn't have a value (it could be set to null). That's why I said you have to check if it has a valid value as well.

I have described in earlier posts how I would do it. I don't what else you want. Do you want me to actually write the code?
Copy linkTweet thisAlerts:
@anishgiriauthorMay 31.2010 — It could potentially exist even if it doesn't have a value (it could be set to null). That's why I said you have to check if it has a valid value as well.

I have described in earlier posts how I would do it. I don't what else you want. Do you want me to actually write the code?[/QUOTE]


I am just thinking that onload assigning value to $_POST ['name'] ( without clicking the submit botton) requires a very little simple piece of code that you will show to me, but I guess it's not that simple, so never mind. I will look at this ajax thing, thanks anyway.
×

Success!

Help @anishgiri spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...