PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 5th, 2006, 06:47 AM
doggerwatson doggerwatson is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 16 doggerwatson User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Combining scripts problem

G'day again
I got the gallery to work when I was using small images; but I want to resize larger images & use them instead.
I had a resize script that works on a single image at a time...but when I put it in to the gallery script doesnt work.
I'm not getting any errors...just no results.

Do I have to do it differently to get the image info from more than 1 result?
The resize starts at line 206.
Can someone please point out what I'm doing wrong here?

<?php


$rowsPerPage = 6;

// by default we show first page
$pageNum = 1;

// if $_GET['page'] defined, use it as page number
if(isset($_GET['page']))
{
$pageNum = $_GET['page'];
}

// counting the offset
$offset = ($pageNum - 1) * $rowsPerPage;



if(IsSet($_GET['Submit']))
{


$linkID = mysql_connect('localhost', 'root', 'sherlock')
or die(
"Error, database not accessing!");

mysql_select_db('twihjlight',$linkID);
$genre = htmlspecialchars($_GET['genre']);

$query = "SELECT
books.Id,
books.Titles,
books.auth_LastName,
books.Genre,
books.Image_Lge,
books.auth_1stName
FROM
`books` WHERE Genre LIKE '%".$_GET['search_field']."%'";
if(!
$result = mysql_query($query, $linkID))
echo
mysql_error($linkID); //cry if the query fails

else //else paginate results

{

//store number of rows returned in a variable $totalrows

$totalrows = mysql_num_rows($result);


$page = $_GET['page'];

if(!IsSet($page))

$page = 1;

if($_GET['results_returned'] == "")

$limit = 4; //use a default value of ten (any positive number will do)

else

$limit = $_GET['results_returned'];

$limitvalue = $page * $limit - ($limit);


if($_GET['numlinks_perpage'] == "") //no number of links specified

$max_links_shown = 6; //use default

else

$max_links_shown = $_GET['numlinks_perpage'];

$query = $query." LIMIT $limitvalue, $limit";

$result = mysql_query($query) or die(mysql_error());
if(
mysql_num_rows($result) == 0) //if no rows returned

echo 'No results returned.';
else
{
echo
$totalrows.' results returned';

//calculate number of pages needed, rounded up

$numofpages = ceil($totalrows / $limit);

$varstring = "&search_field=".$_GET['search_field']."&Submit=".

$_GET['Submit']."&numlinks_perpage=".$_GET['numlinks_perpage'].

"&results_returned=".$_GET['results_returned'];

if($numofpages > 1)
{


if($max_links_shown >= $numofpages)
{
for(
$i = 1; $i <= $numofpages; $i++)
{


//number;

if($i == $page)
echo
"[$i]";
else
echo("<a href="catalogue.php?page=$i?".

$varstring."">$i</a>&nbsp;");
}
}
else

{

if($max_links_shown%2 != 0) //if max links per page is odd

{

$first_page_link = $page - (($max_links_shown - 1)/2);

$last_page_link = $page + (($max_links_shown - 1)/2);
}
else
//max links per page is even

{

$first_page_link = $page -($max_links_shown/2) + 1;

$last_page_link = $page + ($max_links_shown/2);
}

if($first_page_link < 1)
{
for(
$i = $first_page_link; $i < 1; $i++)

$last_page_link++; //increment last link

$first_page_link = 1; //set first link to one

}

//if last link is greater than the number of pages needed

if($last_page_link > $numofpages)
{
for(
$i = $last_page_link; $i > $numofpages; $i--)

$first_page_link--; //decrement first link
//set last link to the number of pages needed

$last_page_link = $numofpages;
}


if($first_page_link != 1)
echo(
"<a href="catalogue.php?page=1?".

$varstring."">First</a> ...&nbsp;");

for($i = $first_page_link; $i <= $last_page_link; $i++)
{
if(
$i == $page) //we don't need a link to the current page
//print the page number with brackets around it

echo "[$i]";
else
//print links to other pages

echo("<a href="catalogue.php?page=$i?".

$varstring."">$i</a>&nbsp;");
}


if($last_page_link != $numofpages)
echo(
"... <a href="catalogue.php?page=$numofpages?".

$varstring."">Last</a>&nbsp;");
}
//end else

}
echo '';
while(
$row = mysql_fetch_array($result)){
$thumb_file=$row['Image_Lge'];
$title= $row['Titles'];
//this is where I tried to do the resize
function setImageSize($thumb_file) {

$maxSize = 150; // set this varible to max width or height

$image_size = getimagesize($_SERVER['DOCUMENT_ROOT'].$thumb_file,&$image_info);
$width = $image_size[0];
$height = $image_size[1];

if($width > $maxSize || $height > $maxSize) {

if($width > $maxSize) {
$z = $width;
$i = 0;
while($z > $maxSize) {
--$z; ++$i;
}
$imgSizeArray[0] = $z;
$imgSizeArray[1] = $height - ($height * ($i / $width));

} else {

$z = $height;
$i = 0;
while($z > $maxSize) {
--$z; ++$i;
}
$imgSizeArray[0] = $width - ($width * ($i / $height));
$imgSizeArray[1] = $z;
}

} else {

$imgSizeArray[0] = $width;
$imgSizeArray[1] = $height;
}

return $imgSizeArray;
$imgSize = setImageSize($row['Image_Lge']);

$pics.='<a href="/books_detail.php?recordID=$row[Id]"><img src="<?php echo $row['Image_Lge']; ?>" width="< php? echo $imgSize[0];?>" height="<? echo $imgSize[1];?>">';
$name=".$title.";


}
}

}
//end paginate results

}

?>
</p>
<p> <?php echo $pics;?><br />

Reply With Quote
  #2  
Old March 6th, 2006, 12:40 AM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,729 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 1 h 32 m 7 sec
Reputation Power: 6
RE: Combining scripts problem

1) What has this to do with PEAR? This belongs in PHP Coding.
2) How are we to know whick line is 206 without sitting here counting them.
3) Please put the code in the forums PHP tags.
4) What have you done for debugging to find out what is wrong? Do you at least have error_reporting set to E_ALL and all error supressions (@) removed? We need a more specific information for what is going wrong.

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > Combining scripts problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT