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.
You can write like this <a href="http://example.com/download.php?filename=pdffile.pdf"><img src="http://example.com/images/image.jpeg"/></a> in download.php you will write code to download the file with header info in it. Please search a good tutorial on it from net.
Thanks for the answer. In the code below how can I assign a value to $_POST['name'] even with out clicking the submit botton? So when the page loaded the $_POST['name'] already has a value that will reflect on the query that will display the data? 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 '%" . $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: " . $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> PHP:
Replace: $pangalan=$_POST['name']; PHP: With: $pangalan = (empty($_POST['name'])) ? "Default Value..." : $_POST['name']; $pangalan = mysql_real_escape_string($pangalan); PHP: