Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I Display an image in here?

Status
Not open for further replies.

overyde

Programmer
May 27, 2003
226
ZA
I found a great script to paginate only problem is I'm not sure how to get the image to display and not the image path. I'm using MySQL and php4.
Here's the script (its oo):

view.php (this where I want the image displayed)
*****************************
<?php
session_start();
require('pagedresults.php');

$cnx = @mysql_connect('localhost','','');
mysql_select_db('online',$cnx);
$rs = new MySQLPagedResultSet(&quot;select * from place&quot;, 1,$cnx);

?>
<html>
<head>
<title>Paged Results Demo</title>
</head>
<body>
<table border=&quot;1&quot;>
<?php while ($row = $rs->fetchArray()):
{$cat = $newArray['user'];}
$picture = $newArray['picture'];
?>
<tr><td width=&quot;100&quot;><?=$row['user']?></td><td><?=$row['picture']?></td></tr>
<?php endwhile; ?>
</table>
<p><?=$rs->getPageNav(&quot;aid=$aid&quot;)?></p>

pagedresults.php (this is the class)
***********************************************
<?php

class MySQLPagedResultSet
{

var $results;
var $pageSize;
var $page;
var $row;

function MySQLPagedResultSet($query,$pageSize,$cnx)
{
$resultpage = $_GET['resultpage'];

$this->results = @mysql_query($query,$cnx);
$this->pageSize = $pageSize;
if ((int)$resultpage <= 0) $resultpage = 1;
if ($resultpage > $this->getNumPages())
$resultpage = $this->getNumPages();
$this->setPageNum($resultpage);
}

function getNumPages()
{
if (!$this->results) return FALSE;

return ceil(mysql_num_rows($this->results) /
(float)$this->pageSize);
}

function setPageNum($pageNum)
{
if ($pageNum > $this->getNumPages() or
$pageNum <= 0) return FALSE;

$this->page = $pageNum;
$this->row = 0;
mysql_data_seek($this->results,($pageNum-1) * $this->pageSize);
}

function getPageNum()
{
return $this->page;
}

function isLastPage()
{
return ($this->page >= $this->getNumPages());
}

function isFirstPage()
{
return ($this->page <= 1);
}

function fetchArray()
{
if (!$this->results) return FALSE;
if ($this->row >= $this->pageSize) return FALSE;
$this->row++;
return mysql_fetch_array($this->results);
}

function getPageNav($queryvars = '')
{
if (!$this->isFirstPage())
{
$nav .= &quot;<a href=\&quot;?resultpage=&quot;.
($this->getPageNum()-1).'&'.$queryvars.'&quot;>Prev</a> ';
}
if ($this->getNumPages() > 1)
for ($i=1; $i<=$this->getNumPages(); $i++)
{
if ($i==$this->page)
$nav .= &quot;$i &quot;;
else
$nav .= &quot;<a href=\&quot;?resultpage={$i}&&quot;.
$queryvars.&quot;\&quot;>{$i}</a> &quot;;
}
if (!$this->isLastPage())
{
$nav .= &quot;<a href=\&quot;?resultpage=&quot;.
($this->getPageNum()+1).'&'.$queryvars.'&quot;>Next</a> ';
}

return $nav;
}
}

?>

</body>
</html>

Reality is built on a foundation of dreams.
 
try this overyde - there are amny ways of displaying images within your page;
<img src=&quot;my.bmp&quot; align= right alt =&quot;My Description&quot;>

JahJah
 
Thanks jahjah.
I was being stupid or blind.
Sorted it out now.
Cheers!

Reality is built on a foundation of dreams.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top