Jump to content

[SOLVED] pass variable to another page..


justAnoob

Recommended Posts

I try to pass the variable to another page.. but it does not work.. check out the commented line.

      <form id="form2" name="form2" method="post" action="updatetrade.php">
        <?php
session_start();
include "connection.php";
if (isset($_GET['pageno']))
{
  $pageno = $_GET['pageno'];
}
else
{
  $pageno = 1;
}
$findit = $_SESSION['id'];
$result = mysql_query("SELECT id FROM members WHERE username = '$findit' LIMIT 1");
$e_row = mysql_fetch_assoc($result);
$query = mysql_query("SELECT count(*) FROM abcxyz WHERE user_id = " . $e_row['id']) or die(mysql_error());


$query_data = mysql_fetch_row($query);
$numrows = $query_data[0];
$rows_per_page = 1;
$lastpage = ceil($numrows/$rows_per_page);
$pageno = (int)$pageno;
$prevpage = $pageno-1;
$nextpage = $pageno+1;


if ($pageno > $lastpage)
{
  $pageno = $lastpage;
}
if ($pageno < 1)
{
  $pageno = 1;
}
$limit = 'LIMIT ' .($pageno - 1) * $rows_per_page .',' .$rows_per_page;

$sql = mysql_query("SELECT id, category, imgpath, imgpath2, imgpath3, imgpath4, imgpath5, item_name, description, in_return FROM abcxyz WHERE user_id = " . $e_row['id'] . " $limit");   

if($lastpage != 0)
{
echo "<table width='954' border='0' align='center' cellpadding='0' cellspacing='0' bordercolor='#000000' bgcolor='#BBD4E1'>";
while ($row = mysql_fetch_array($sql))
{
echo "<tr><td width='188' height='180'><div align='center'>";
echo '<img src="' . $row['imgpath'] . '" width="125" alt="" />';
echo "</div></td><td width='188'><div align='center'>";
if(empty($row['imgpath2']))
{
  echo '<a href="picture2.php">Click to Upload Picture #2.</a>';
}
else
{
  echo '<img src="' . $row['imgpath2'] . '" width="125" alt="" />';
}
echo "</div></td><td width='188'><div align='center'>";
echo '<img src="' . $row['imgpath3'] . '" width="125" alt="" />';
echo "</div></td><td width='188'><div align='center'>";
echo '<img src="' . $row['imgpath4'] . '" width="125" alt="" />';
echo "</div></td><td width='190'><div align='center'>";
echo '<img src="' . $row['imgpath5'] . '" width="125" alt="" />';
echo "</div></td></tr><tr><td height='43' colspan='4'>";
echo '<strong>Item Name:</strong> <input type="text" name="item_name" value="' . $row['item_name'] . '" size="50" />   ';
if ($pageno == 1)
{
  echo " Previous Item ";
}
else
{
  echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$prevpage'> Previous Item </a>";
}
echo "($pageno of $lastpage)";
if ( $pageno == $lastpage )
{
  echo " Next Item ";
}
else
{
  echo "<a href='{$_SERVER['PHP_SELF']}?pageno=$nextpage'> Next Item </a>";
}
echo "</td><td><div align='center'>";
echo '<input type="hidden" name="id" value="' . $row['id'] . '" size="25" />';
echo "</div></td></tr><tr><td height='116' colspan='4'>";
echo '<strong>Description:</strong> <textarea name="description" cols="75" rows="5">' . $row['description'] . '</textarea>';
echo "</td><td><div align='center'>";
echo '<input type="submit" name="submit" id="submit" value="Update Item">';
echo "</div></td></tr><tr><td height='124' colspan='4'>";
echo '<strong>Seeking:</strong>       <textarea name="in_return" cols="75" rows="5">' . $row['in_return'] . '            </textarea>';
echo "</td><td><div align='center'>";
if(isset($_SESSION['updatecomplete']))
{
  unset($_SESSION['updateerror']);
  echo $_SESSION['updatecomplete'];
}
if(isset($_SESSION['updateerror']))
{
  unset($_SESSION['updatecomplete']);
  echo $_SESSION['updateerror'];
}
echo "</div></td></tr><tr><td colspan='4'>";
echo '<input type="hidden" name="category" value="' . $row['category'] . '" size="25" />';
echo "</td><td><div align='center'>";
echo '';
echo "</td></tr>";
}
echo "</table>";
$_SESSION['item_id_pass'] = $row['id'];   // I try to echo this session var on another page,, but it does not appear.
}
else
{
  echo '<div align="center">You currently have no pics.<br />Post your first pic now!</div>';
}
?>
      </form>

Link to comment
Share on other sites

justAnoob, please use better formatting. It's such a pain for others to help you when they have to painfully find all your matching closing braces because of poor indentation. It's hard for you too. Even if you like it like that, please consider indenting it and using better format if you want others to help you.

 

$row is *not* defined outside of the while loop. If you had formatted your code, you would have known that easily. :P

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.