/    Sign up×
Community /Pin to ProfileBookmark

hello, i am writing a php file called books.php which queries a table named ‘products’ from a database and displays the book information it contains. In addition, to other fields, each book in the products table in the IC2A2_07.mdb (name of the database) database has a field called coverart the value of which refers to the jpg file name which is the book cover image of the respective book. I have created a folder to store the cover images of all books to reduce server burden.

however, i am having trouble with the php coding to display the pictures of the books. does anyone know how to go about displaying them? i plan to do them under the ‘coverart’ variable. This is as far as ive gotten.

[code=php]<?php
$conn=odbc_connect(‘IC2A2_07’,”,”);

if (!$conn) {
exit(“Connection Failed: ” . $conn);
}

$sql=”SELECT * FROM products”;

$rs=odbc_exec($conn,$sql);

if (!$rs) {
exit(“Error in SQL”);
}

// table creation

print “<table><tr>”;
print “<th>ID</th>”;
print “<th>title</th>”;
print “<th>authors</th>”;
print “<th>Date</th>”;
print “<th>edition</th>”;
print “<th>isbn</th>”;
print “<th>coverart</th>”;
print “<th>price</th>”;
print “<th>select</th></tr>”;

while (odbc_fetch_row($rs)) {

$ID=odbc_result($rs,”ID”);
$title=odbc_result($rs,”title”);
$authors=odbc_result($rs,”authors”);
$Date=odbc_result($rs,”publishDate”);
$edition=odbc_result($rs,”edition”);
$isbn=odbc_result($rs,”isbn”);
$coverart=odbc_result($rs,”coverart”);
$price=odbc_result($rs,”price”);

print “<tr><td>$ID</td>”;
print “<td>$title</td>”;
print “<td>$authors</td>”;
print “<td>$Date</td>”;
print “<td>$edition</td>”;
print “<td>$isbn</td>”;
print “<td>$coverart</td>”;
print “<td>$price</td>”;
print “<td>$select</td></tr>”;
}

odbc_close($conn);
echo “</table>”;
?>[/code]

any help would be much appreciated, thanks (:

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@Mester_PedizOct 21.2007 — Now i dunno exactly what data there's in your $coverart variable but i would guess that you should try and change

[code=php]print "<td>$coverart</td>";[/code]

to

[code=php]print "<td><img src="".$coverart.""></td>"; [/code]
×

Success!

Help @Hackurate 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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