Jump to content

Incrementing and decrementing URL variables


mjurmann

Recommended Posts

Hello. I am trying to use PREVIOUS and NEXT arrows to increment the variable "id" in the URL string so that each time a button is selected, the the id will be incremented or decremented thus pulling all ids with "2" or "0" (depending on what arrow is clicked) out on the next page. Here is what I have so far:

<div align="center">

  <div id="image_navigation"> <a href="gallery.php?id=<?php echo        $row_Recordset1['id']-1; ?>"><img src="../images/previous.jpg" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="gallery.php?id=<?php echo $row_Recordset1['id']+1; ?>"><img src="../images/next.jpg" border="0" /></a>

  </div>

</div>

The site where this is not working is:

http://www.hotheadbeads.com/htms/gallery.php?id=1

As you can see, the arrows do not +1 or -1 when clicking on the arrows. Help please!
Link to comment
Share on other sites

Without seeing more of ur code I think u should do the calculation outside of the link and echo the result in the link like this

[code]

$plus = $rec_Recordset1['id'] + 1;
$minus = $rec_Recordset1['id'] - 1;




<div align="center">

  <div id="image_navigation"> <a href="gallery.php?id=<?php echo        $minus; ?>"><img src="../images/previous.jpg" border="0" />[/url]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="gallery.php?id=<?php echo $plus; ?>"><img src="../images/next.jpg" border="0" />[/url]

  </div>

</div>

[/code]
Link to comment
Share on other sites

<?php

$plusone=$row_Recordset1['id']++;
$minusone=$row_Recordset1['id']--;

I did that, but it still isn't working. Here is all of my code:
[code]

<?php require_once('../Connections/hotheadbeads.php'); ?>
<?php

$colname_Recordset1 = "-1";
if (isset($_GET['id'])) {
  $colname_Recordset1 = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($database_hotheadbeads, $hotheadbeads);
$query_Recordset1 = sprintf("SELECT * FROM gallery WHERE id = '%s' ORDER BY caption ASC", $colname_Recordset1);
$Recordset1 = mysql_query($query_Recordset1, $hotheadbeads) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);
?><!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>Hotheadbeads.com  |  Flame-torched Glass by Teri Wathan</title>
<link href="http://www.hotheadbeads.com/css/styles.css" rel="stylesheet" type="text/css" />
</head>

<body bgcolor="#000000">

<div align="center">

<div id="container">


<div id="header"></div>

<div id="body">

<div id="left_column">

<div class="cssnav">
<a href="http://www.hotheadbeads.com"/><img src="http://www.hotheadbeads.com/images/nav/home1.jpg" alt="" width="192" height="28" /></a> </div>

<div class="cssnav2">
<a href="http://www.hotheadbeads.com/htms/gallery.php?id=1"/><img src="http://www.hotheadbeads.com/images/nav/gallery1.jpg" alt="" width="192" height="28" /></a> </div>

<div class="cssnav3">
<a href="http://www.hotheadbeads.com/htms/specials.php"/><img src="http://www.hotheadbeads.com/images/nav/specials1.jpg" alt="" width="192" height="28" /></a> </div>

<div class="cssnav4">
<a href="http://www.hotheadbeads.com/htms/aboutme.php"/><img src="http://www.hotheadbeads.com/images/nav/aboutme1.jpg" alt="" width="192" height="28" /></a> </div>


<div class="cssnav5">
<a href="http://www.hotheadbeads.com/blog/"/><img src="http://www.hotheadbeads.com/images/nav/blog1.jpg" alt="" width="192" height="28" /></a> </div>

<div class="cssnav6">
<a href="http://www.hotheadbeads.com/htms/contact.php"/><img src="http://www.hotheadbeads.com/images/nav/contact1.jpg" alt="" width="192" height="28" /></a> </div>


<div class="cssnav7">
<a href="http://search.ebay.com/_W0QQsassZhotheadbeads" onclick="window.open(this.href,'newwin'); return false;"/><img src="http://www.hotheadbeads.com/images/nav/ebaylistings1.jpg" alt="" width="192" height="28" /></a> </div>


<div id="mailing_list">
  <form id="form1" name="form1" method="post" action="">
    <table width="95%" border="0" cellspacing="2" cellpadding="0">
                      <tr>
                        <td><label>
                          <input name="email" type="text" id="email" size="16" />
                        </label></td>
                      </tr>
                      <tr>
                        <td>&nbsp;</td>
                      </tr>
                 
                      <tr>
                        <td><label>
                          <input type="image" src="http://www.hotheadbeads.com/images/submit_btn.jpg" name="Submit" value="Submit" />
                        </label></td>
                      </tr>
                    </table>
                  </form>
    </div>


</div>

<div id="right_column">
<img src="http://www.hotheadbeads.com/images/gallery_msg.jpg" /><br /> <br />



  <div class="gallerycontainer">

    <?php do { ?>
        <br />
                <a class="thumbnail" href="#thumb"><img src="<?php echo $row_Recordset1['image']; ?>" border="0" /><span><img src="<?php echo $row_Recordset1['largeimage']; ?>" /><br />
                <?php echo $row_Recordset1['caption']; ?></span></a>
      <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>


<br />
  </div>

<?php

$plusone=$row_Recordset1['id']++;
$minusone=$row_Recordset1['id']--;

?>

<div align="center">
<div id="image_navigation"> <a href="gallery.php?id=<?php echo $minusone; ?>"><img src="../images/previous.jpg" border="0" /></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="gallery.php?id=<?php echo $plusone; ?>"><img src="../images/next.jpg" border="0" /></a></div>
</div>


  </div>



</div>


<div id="footer"></div>





</div>

</div>


</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.