Help
Search
Login
Register
Home
Forum: web design and graphics community
Celestial Star Forum
>
Web Development
>
Coding
>
PNG Database Preview
Pages: [
1
]
« previous
next »
Print
Author
Topic: PNG Database Preview (Read 2584 times)
SilverMoon
Angeling
Posts: 4
PNG Database Preview
«
on:
July 01, 2006, 03:47:00 PM »
I was wondering how you would display the PNG in a coded page like seen on Aethereality and Beloved Melody instead of the PNG being seen on a blank window.
Thanks in advance!
Logged
i>To become like
me
, you must walk the
sinful
path...
Blackstone
Administrator
Valkyrie Randgris
Posts: 821
Oh look! People!
PNG Database Preview
«
Reply #1 on:
July 01, 2006, 05:21:49 PM »
It all depends on your coding. I'm afraid I can't help you unless I see your coding...
Logged
SilverMoon
Angeling
Posts: 4
the coding..
«
Reply #2 on:
July 01, 2006, 06:11:39 PM »
ok.
Code:
<?
// header stuff
// connection variables
$q="SELECT * FROM pngs ORDER BY 'id' DESC ";
$result= mysql_query($q, $connection) or die
("Cannot connect to the database: " . mysql_error());
$screen = $_GET['screen'];
$PHP_SELF = $_SERVER['PHP_SELF'];
$rows_per_page = 4;
$total_records = mysql_num_rows($result);
$pages = ceil($total_records / $rows_per_page);
if (!isset($screen))
$screen=0;
$start = $screen * $rows_per_page;
$q .= "LIMIT $start, $rows_per_page";
$result= mysql_query($q) or die
("Could not execute query : $q." . mysql_error());
while ($row=mysql_fetch_array($result))
{
$id=$row["id"];
$thumbnail=$row["thumbnail"];
$date=$row["date"];
$series=$row["series"];
$artist=$row["artist"];
$download=$row["download"];
$date = explode("-", $date);
if ($date[1]==1) $month = "January";
if ($date[1]==2) $month = "February";
if ($date[1]==3) $month = "March";
if ($date[1]==4) $month = "April";
if ($date[1]==5) $month = "May";
if ($date[1]==6) $month = "June";
if ($date[1]==7) $month = "July";
if ($date[1]==8) $month = "August";
if ($date[1]==9) $month = "September";
if ($date[1]==10) $month = "October";
if ($date[1]==11) $month = "November";
if ($date[1]==12) $month = "December";
$date = $month . " " . $date[2] . ", " . $date[0];
echo "
<table width=\"325\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"font\" align=\"center\">
<tr>
<td id=\"pngheader\" colspan=\"2\">$series</td>
</tr>
<tr>
<td><div style=\"padding-top: 10px; padding-bottom: 10px; border-bottom: 1px dotted #000000;\" align=\"center\"><img src=\"$thumbnail\" border=\"0\" alt=\"\" /></div></td>
<td valign=\"middle\" style=\"border-bottom: 1px dotted #000000;\">
<div style=\"padding: 5px;\" id=\"font\">
<b>ID:</b> $id<br>
<b>Artist:</b> $artist<br>
<b>Series:</b> $series<br>
<b>Date:</b> $date<br>
<br>
<center>
<a href=\"$download\" target=\"_blank\">[ Download PNG ]</a>
</center>
</div>
</td>
</tr>
</table><br>";
}
{
echo "<center>";
if ($screen > 0) {
$j = $screen - 1;
$url = "$PHP_SELF?screen=$j";
echo "| <a href=\"$url\">« Prev</a>";
}
$p = 5;
$lower = $p;
$upper = $screen+$p;
while($upper>$pages){
$p = $p-1;
$upper = $screen+$p;
}
if($p<$lower){
$y = $lower-$p;
$to = $screen-$y;
while($to<0){
$to++;
}
}
if(!empty($to))
{
for ($i=$to;$i<$screen;$i++){
$url = "$PHP_SELF?screen=" . $i;
$j = $i + 1;
echo " | <a href=\"$url\">$j</a> | ";
}
}
for ($i=$screen;$i<$upper;$i++) {
$url = "$PHP_SELF?screen=" . $i;
$j = $i + 1;
echo " | <a href=\"$url\">$j</a> |";
}
if ($screen < $pages-1) {
$j = $screen + 1;
$url = "$PHP_SELF?screen=$j";
echo "<a href=\"$url\">Next »</a>|";
}
}
echo "</center>";
// footer details
?>
Logged
i>To become like
me
, you must walk the
sinful
path...
Melfina
Administrator
Valkyrie Randgris
Posts: 1289
PNG Database Preview
«
Reply #3 on:
July 02, 2006, 01:45:19 PM »
I guess $download is the url of your your PNG right?
You can do it by creating a new png, for example, download.php and change the link on your png display page from <a href=\"$download\"> to <a href=\"dowload.php?id=$id\">
Then, at the download.php page, connect to the database and run a query that searches for that certain id and display it, something like this:
Code:
<?
$id = $_GET['id'];
// header stuff
// connection variables
$q="SELECT * FROM pngs WHERE id='$id' ";
$result= mysql_query($q, $connection) or die
("Cannot connect to the database: " . mysql_error());
while ($row=mysql_fetch_array($result))
{
$id=$row["id"];
$thumbnail=$row["thumbnail"];
$date=$row["date"];
$series=$row["series"];
$artist=$row["artist"];
$download=$row["download"];
$date = explode("-", $date);
if ($date[1]==1) $month = "January";
if ($date[1]==2) $month = "February";
if ($date[1]==3) $month = "March";
if ($date[1]==4) $month = "April";
if ($date[1]==5) $month = "May";
if ($date[1]==6) $month = "June";
if ($date[1]==7) $month = "July";
if ($date[1]==8) $month = "August";
if ($date[1]==9) $month = "September";
if ($date[1]==10) $month = "October";
if ($date[1]==11) $month = "November";
if ($date[1]==12) $month = "December";
$date = $month . " " . $date[2] . ", " . $date[0];
echo "<center><img src=\"$download\" alt=\"\" /></center>";
}
// footer details
?>
You could also do it without connecting to the database again, but you wouldn't be able to display the other mysql data when downloading a png, such as the artist, date etc... and the url would be longer, but it would save some server resources :arrow:
Code:
<?
$url = $_GET['url'];
// header stuff
echo "<center><img src=\"$url\" alt=\"\" /></center>";
// footer details
?>
Using this, you would need to change the link at your normal png page (where you show all pngs) from <a href=\"$download\"> to <a href=\"dowload.php?url=$download\">
I hope it helps
Logged
MySpace
~
MySpace Codex
~
Rune Nifelheim
SilverMoon
Angeling
Posts: 4
PNG Database Preview
«
Reply #4 on:
July 02, 2006, 04:47:44 PM »
thanks a lot for the help melfina! i really appreciated it! xD
Logged
i>To become like
me
, you must walk the
sinful
path...
Pages: [
1
]
Print
« previous
next »
Jump to:
Please select a destination:
-----------------------------
General
-----------------------------
=> General
=> New Members
=> Announcements
=> Support / Suggestions
-----------------------------
Contests
-----------------------------
=> Archive
===> Contests
===> Blend Challenges
===> SOTW
-----------------------------
Art Boards
-----------------------------
=> Creative mediums
=> Requests & offers
=> Tutorials
===> Celestial Star Tutorials
-----------------------------
Web Development
-----------------------------
=> Coding
=> Web Design
=> Advertisements / Affiliation
-----------------------------
Off-topic
-----------------------------
=> Entertainment
-----------------------------
Español (Spanish Only)
-----------------------------
=> General / Bienvenida
=> Anuncios / Ayuda
=> Código / Desarrollo web
Welcome,
Guest
Members login
Register for free
General
General
New members
Announcements
Support / Suggestions
Art boards
Creative mediums
Requests and offers
Tutorials
Celestial Star tutorials
Web development
Coding
Web design
Advertisements / affiliation
Off-topic
The non-sense
Ententainment
Loading...