General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old December 10th, 2002, 01:11 AM
DivaX007 DivaX007 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Nov 2002
Posts: 23 DivaX007 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
One For Each

i have included a rating script in a gallery script using include(). the drop down rating box appears only once when i test the script, but i need it to appear beside each image. how do i do this?

<?php

// Connects to sql server and logs in with username and password
// if successful, then the script moves on to displaying the gallery.

$connect=mysql_connect("localhost","xxxx","xxx")
or die("couldnt connect to sql server");

$db= mysql_select_db("dbname") or die ("couldnt select database");

include("./rate.php");

// Ive set the number of photos per page, in this case I only have 7 photos
// so I want to display 1 photo per page.

$per_page = 1;

// Selects all of the data from database

$sql_text = ("SELECT * from photogallery ORDER BY id DESC");

// Sets page number, if no page is specified, it will create page 1

if(!$page) {
$page = 1;
}
$prev_page = $page - 1;
$next_page = $page + 1;


$query = @mysql_query($sql_text);

// Sets up specified page

$page_start = ($per_page * $page) - $per_page;

$num_rows = @mysql_num_rows($query);

if($num_rows <= $per_page) {
$num_pages = 1;
}
else if (($num_rows % $per_page) == 0) {
$num_pages = ($num_rows / $per_page);
}
else {
$num_pages = ($num_rows / $per_page) + 1;
}
$num_pages = (int) $num_pages;

if (($page > $num_pages) || ($page < 0)) {
error("You have specified an invalid page number");
}

$sql_text = $sql_text . " LIMIT $page_start, $per_page";
$query = mysql_query($sql_text);

?>


<!-- This starts the web page with HTML and PHP embedded. -->
<!-- It also counts how many photos are present in the photo gallery. -->

<title>My Photo Gallery</title>
<body bgcolor="#ffffff">
<blockquote> There are currently<font color="red">
<?php echo "$num_rows"; ?> </font> photos in My Photo Gallery<p>

<!-- It loops through the rows and obtains the data that we created in the table. -->

<?php
while ($result = mysql_fetch_array($query))
{
$title = $result["title"];
$photo = $result["photo"];

$linkToFullPhoto = $result["link2Full"];

// Using HTML "img" tags for the photos, it selects the photo by it's "id" number

echo $title.'<br />

<a href="'.$linkToFullPhoto.'">

<img src="'.$photo.'" border="0">

</a><p />

<hr width="400" align="left">';
}

// This displays the "Previous" link

if ($prev_page) {
echo "<a href=\"$PHP_SELF?page=$prev_page\">< Prev</a>";
}

// This loops the Pages and displays individual links corresponding
// to the photos.

for ($i = 1; $i <= $num_pages; $i++) {
if ($i != $page) {
echo " <a href=$PHP_SELF?page=$i>$i</a>";
} else {
echo " $i ";
}
}

// This displays the "Next" link.

if ($page != $num_pages) {
echo " |<a href=\"$PHP_SELF?page=$next_page\"> Next ></a>" ;
}

?>

</blockquote>
</body>
</html>

_____________

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > One For Each


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 3 hosted by Hostway
Stay green...Green IT