WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-10-2006, 09:54 PM
WebProWorld Member
 

Join Date: Aug 2003
Location: Jersey City, NJ
Posts: 71
jazzmatazz2005 RepRank 0
Default Displaying images

I put together a page and it gets its information from a mysql database.
This is the code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>

<body>
<?php
$dbhost = 'localhost';
$dbuser = 'username';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error connecting to mysql');
$dbname = 'database1';
$out = mysql_select_db($dbname,$conn) or die(mysql_error($conn));
$table = 'links';//Table name here
$limit = 10;//Limit of results here
$page = $_GET['page'];//Gets the page
$totalrows = mysql_num_rows(mysql_query("SELECT ModelName FROM $table"));//Get the total rows of the table
if(empty($page))//If the page is empty
{
$page = '1';//sets the page to 1
};
$start = ($page-1)*$limit;//set the start page
$start = round($start,0);//rounds it
$result = mysql_query("SELECT * FROM $table LIMIT $start, $limit");//makes the query, here you can add for example
//WHERE something='somethingelse'
while ($r = mysql_fetch_array($result))
{
echo "$r[ModelName]
";
echo "$r[ModelGroupUrl]
";
echo "$r[SiteStatus]
'";
echo"<img src=\"$ImageLocation\" width=150 height=150>

";
};
$totalpages = $totalrows / $limit;//Gets the totalpages
$totalpages = ceil($totalpages);//rounds them to the bigger number, so if the limit is 10 and there are 11 results it will show 2 paegs instead of 1 :)
if($page == 1)//if the page is 1
{
$actualpage = '[1]';//actial page 1
}
else
{
$actualpage = "[$page]";//else actualpage is the one we get using the $_GET
}
if($page < $totalpages)//if the page is smaller than totalpages
{
$nv = $page+1;//next page
$pv = $page-1;//prev page
$nextpage = "<a href=?page=$nv>></a>";//next page link
$prevpage = "<a href=?page=$pv><</a>";//preg page link
$firstpage = "<a href=\"?page=1\">«</a>";//first page
$finalpage = "<a href=\"?page=$totalpages\">»</a>";//last page
}
if($page == '1')//if the page is 1
{
$nv = $page+1;
$nextpage = "<a href=?page=$nv>> </a>";
$prevpage = "<";
$firstpage = "«";
$finalpage = "<a href=\"?page=$totalpages\">»</a>";
}elseif($page == $totalpages){//is the page is equal than the totalpages
$pv = $page-1;
$nextpage = ">";
$prevpage = "<a href=?page=$pv><</a>";
$firstpage = "<a href=\"?page=1\">«</a>";
$finalpage = "»";
}
if($totalpages == '1' || $totalpages == '0'){//if totalpages is 1 or 0
$nextpage = ">";
$prevpage = "<";
$firstpage = "«";
$finalpage = "»";
}
echo "$firstpage $prevpage $actualpage $nextpage $finalpage
Pages: $totalpages";//echoes the pages at the botton of the file
?>

</body>
</html>
The problem im having is, i want it to display a image. The url of the image is stored in the DB. I also want it to display links that are stored in the DB as links on the displayed page.

I tried several differnt things and nothing seems to work. Can i get some help
__________________
It's better to do business with me than against me!
Reply With Quote
  #2 (permalink)  
Old 09-12-2006, 09:48 PM
WebProWorld Member
 

Join Date: Aug 2003
Location: Jersey City, NJ
Posts: 71
jazzmatazz2005 RepRank 0
Default ok

Can Anybody help me
__________________
It's better to do business with me than against me!
Reply With Quote
  #3 (permalink)  
Old 09-13-2006, 10:07 AM
sands's Avatar
WebProWorld Veteran
 

Join Date: Sep 2005
Location: Kerala, India
Posts: 397
sands RepRank 1
Default Re: ok

Quote:
Originally Posted by jazzmatazz2005
The problem im having is, i want it to display a image. The url of the image is stored in the DB.
But where is the image? Is only the URL in the database or the image itself? Is $ImageLocation the URL?
Code:
"<img src=\"$ImageLocation\" width=150 height=150>
Shouldn't this be:
Code:
"<img src=\"$r[ImageLocation]\" width=150 height=150>
Quote:
Originally Posted by jazzmatazz2005
I also want it to display links that are stored in the DB as links on the displayed page.
What is the problem with this?
__________________
My Nook | My Biz | My Photos
Reply With Quote
  #4 (permalink)  
Old 09-14-2006, 11:08 AM
WebProWorld Member
 

Join Date: Aug 2003
Location: Jersey City, NJ
Posts: 71
jazzmatazz2005 RepRank 0
Default

Thanks sands...
all my images are displaying fine now.

I have links stored in the db and i want to display them on the page. the code that im useing now

Code:
echo "<A HREF=\"$r[ModelGroupUrl]\"
";
gets the link, but makes all the text in the row apart of the same link.
__________________
It's better to do business with me than against me!
Reply With Quote
  #5 (permalink)  
Old 09-14-2006, 08:32 PM
sands's Avatar
WebProWorld Veteran
 

Join Date: Sep 2005
Location: Kerala, India
Posts: 397
sands RepRank 1
Default

Quote:
Originally Posted by jazzmatazz2005
I have links stored in the db and i want to display them on the page. the code that im useing now

Code:
echo "<A HREF=\"$r[ModelGroupUrl]\"
";
gets the link, but makes all the text in the row apart of the same link.
It should be:
Code:
echo "<A HREF=\"$r[ModelGroupUrl]\">$r[ModelGroupUrl]</a>
";
Or
Code:
echo "<A HREF=\"$r[ModelGroupUrl]\">Link Text</a>
";
__________________
My Nook | My Biz | My Photos
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Tags: ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0