PDA

View Full Version : php



vidura123
03-01-2006, 07:08 AM
I want to save the pictures (jpg files) in the database and i want to view that pictures using php. please help me. what is the code for that?

Twey
03-01-2006, 04:15 PM
It's exactly the same as reading/writing anything else to/from a database. Make sure, though, that the row/column* you're writing it into allows binary input. In MySQL, this means it needs to be of the BLOB type with its BINARY attribute set.
Then, just store/retrieve it normally, and use a header("Content-Type: image/jpeg"); statement to set the MIME-type correctly before echoing the data to the browser.

* preferred visualisation varies depending on database package.

djr33
03-02-2006, 08:23 AM
not to drag this off topic, but a quick question about the MIME-type command...

I saw that as an example for a page that was a php-generated image... and it's url was .../image.php, but it was just like a .jpg viewed as its own page.

Would you still need to include the MIME-type command if you were using the image in a page, such as the <img ...> command?

I might be missing something.

mwinter
03-02-2006, 11:26 AM
I saw that as an example for a page that was a php-generated image... and it's url was .../image.php, but it was just like a .jpg viewed as its own page.

Would you still need to include the MIME-type command if you were using the image in a page, such as the <img ...> command?Yes. The user agent will (or at least should) depend upon the Content-Type HTTP header to determine how to handle a file. An accurate Content-Type header should be sent with every HTTP response that contains an entity body (returned content).

Mike

vidura123
03-03-2006, 04:11 AM
I solved that problem.
Another problem If I clike a button i want to view the data in another page.
(only using php)

djr33
03-03-2006, 05:07 AM
Huh? Not too clear.

<form action='OTHERPAGE'>
<input type='submit'>
</form>

That would work. Put it inside an echo tag if you need it to be displayed by php.

...
echo "[insert above code]";
...

vidura123
03-08-2006, 05:38 AM
code is ok. But i want to pass a value to other page.
eg:- ______ search.
here i want to give a value (eg: name) for search & view the details of that data(eg:- age, firstname, lastname, etc...) another page using php.

Twey
03-08-2006, 07:40 AM
<form action='OTHERPAGE' method="post">
<input type="text" name="search">
<input type='submit' value="Search">
</form>On the PHP page, retrieve the value using
$_POST['search']

vidura123
03-09-2006, 08:34 AM
I want to insert a picture inside the php code.
echo(" <tr> <td height=\"17\"><img src=\"a.jpg\" width=\"748\" height=\"20\"></td> </tr>");
is it correct?
But it is not working. why?

Twey
03-09-2006, 09:45 AM
You don't insert a picture into PHP code; you cause PHP to output the HTML to display the picture.
That is correct. Is the code being called?

vidura123
03-10-2006, 08:10 AM
That coding is not working. Without php, only using html, it is working.

Twey
03-10-2006, 04:16 PM
Are you certain the code is being called?