Forum Moderators: coopster

Message Too Old, No Replies

image link?

image links?

         

kingofpiracy

8:00 pm on Jun 1, 2005 (gmt 0)

10+ Year Member



How would i setup a php page or whatever to have an image linked to another website?

and in the status bar it shows: mywebsite.com/id?1234

would i have to setup a txt file or php file or what, and what would the php code(s) be? I am a newbie at php!

mcibor

9:26 pm on Jun 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



this means that you have image url stored in db,eg mysql in a table:

CREATE TABLE img (id INT NOT NULL auto_increment, url VARCHAR(70) default '#', title VARCHAR(70), description BLOB, PRIMARY KEY(id));

this is index.php that will show the file:

<?php
if(!($id = (int)$_GET["id"])) $id = 1;
mysql_connect("host", "name", "password") or die(mysql_error());
mysql_select_db("dbname") or die(mysql_error());
$sql = "SELECT url, title, description FROM img WHERE id='$id';
$ans = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_array($ans);
?><html><head>....bla bla</head><body><p><?php echo $row["title"];?></p>
<img src="<?php echo $row['url'];?>"><br><p>

mcibor

9:28 pm on Jun 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[quote]<?php
print(str_replace("\n", "<br>", $row["description"]));
?></p><a href="index.php?id=<?php print($id - 1);?>">Previous picture</a><a href="index.php?id="<?php print($id + 1);?>>Next picture</a></body></html>[quote]

You should also give pages and check if you don't exceed max picture and not write id=0. But I hope this gives you some insight in how to start that
Best regards
Michal Cibor

kingofpiracy

6:37 am on Jun 2, 2005 (gmt 0)

10+ Year Member



WOW, nice code! :)
Where do I edit the code at to suit my needs?

And thanks for the quick reply!

mcibor

9:11 am on Jun 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Correct "host", "name", "password" and "dbname" to your database. Correct SELECT statement to select things you want to put out from the table img (img might not be your table name as well).However with the table I provided it should stay.
Convert html to your needs. Only leave <?php?>

There shouldn't be any[quote] - it's my mistake.

What you also need is to check if you don't exceed above ids (below is not a problem).

Best regards!
Michal Cibor

kingofpiracy

2:45 pm on Jun 2, 2005 (gmt 0)

10+ Year Member



Ok, I understand now, thanks man!