/    Sign up×
Community /Pin to ProfileBookmark

image and text

Hi,

I want to store an image and an asscoicated text comment in a mysql table, and be able to load them both using php. How do i store this data to be easily read onto a webpage, using php.

I don’t know what header command to display.
I try this but it fails so how do you display an image and text from a php file . I can display an image on its own but I don’t kow how to add text as echo command fails.

header(“Content-type: image/jpeg, text/plain”);

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@avaNov 13.2006 — Hi,

It's a little vague what you want to do exactly. How about this?

mysql table:

images

-id int auto_increment not null primary_key,

-link varchar(50) not null,

-text mediumtext null

Use the following code to display and store (no headers needed):

[code=php]//Display images (assuming you're already connected to database)
$query = "SELECT link,text FROM images ORDER BY id";
$result = mysql_query($query);
while ($row = mysql_fetch_row($result))
{
$link = $row[0];
$text = $row[1];
echo "<img src="$link" border="0" alt="$text">";
}

//Store image. $link and $text must be read somewhere
$query = "INSERT INTO images (link,text) VALUES ("$link","$text")";
mysql_query($query);[/code]

Is this what you meant?
×

Success!

Help @jagguy 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 5.24,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...