0

I'm trying to develop an interactive website using php and i want to display image(retrived from mysql database) and some text on the home pag. but the image retrived from my database fills the whole page. how can i display both text and image on the same page?

4
Contributors
9
Replies
12
Views
5 Years
Discussion Span
Last Post by diafol
0
<?php
    $username = 'root';
    $password= '';
    $host = 'localhost';
    $id = $_GET['image_id'];
    $con = mysql_connect($host,$username,$password) or die ('connection error');
    $db = mysql_select_db('test');
    $query = "select * from photo_galary where id=" . $id; //the fields are order as id,photo
    $result = mysql_query($query) or die('query error');
    $row = mysql_fetch_row($result);
    $content = $row[1];
    header('Content-type: image/jpg');
    echo $content;
    echo 'Some text here';
    exit();
?>
0

Are you saving image path or image data in database?? It is working for me for image data.

0

i save it as image data and it displays the image but the image fills the whole page. I want to display both the image and the text.

0

i think you may need to set up a box to put the img in ,

echo '<td><img width="300" src="',$row['pic'],'"/></a></td>';

thats how i keep mine to 300 wide, the hight is var. however you could add hight="300" i think

0

Fo the image:

echo "<td><img width=\"300\" src=\"{$row['pic']}\" /></td>";

If you're saving paths. If using data, as you state. Have:

<img src="image.php?id=7" width="300" />

Where the id=7 is the image id from the DB and image.php contains your code.

Edited by diafol

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.