Passing variable with previous next

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,
I am working on a page that first collects a variable using POST, and which
then uses same in the page which processed this variable. Everything works
fine if I run the page with the variable already set (i.e. do not send it
via POST from the page which calls the script. I have included what I think
are the important parts below. Any help greatly appreciated, as this is my
first time to post to this list.
Thanks,
Declan.

(a) Page which calls the script - form.php

<form action="results2.php" method='POST'">
 <B>County:</B><br>
     <select name="address_region">
     <option value="none">select county
     <option value="Co. Carlow">Co. Carlow
     <option value="Co. Clare">Co. Clare
     <option value="Co. Cork">Co. Cork
     </select>
<input type="submit" name="submit" value="Submit">

(b) Page which processes the passed variable.

<?php
   include 'db.inc';
   include 'error.inc';

   // Open a connection to the DBMS
   if (!($connection = @ mysql_connect($hostName,
                                       $username,
                                       $password)))
      die("Could not connect to database");

   if (!mysql_select_db("processors_list2", $connection))
      showerror();



 $company_name = $HTTP_POST_VARS['company_name'];

$limit = 5;
$query_count = "SELECT * FROM sheet1 WHERE
address_region='$address_region'";
$result_count = mysql_query($query_count);
$totalrows = mysql_num_rows($result_count);
$page = $_GET['page'];
if(empty($page))

$page = 1;
$limitvalue = $page * $limit - ($limit);
$query = "SELECT * FROM sheet1 WHERE address_region='$address_region' LIMIT
$limitvalue, $limit";
$result = mysql_query($query) or die("Error: " . mysql_error());

if(mysql_num_rows($result) == 0)
echo("Nothing to Display!");

echo "\n<table width=\"100%\" align=\"center\" border=\"0\">";

while($row = mysql_fetch_array($result))

{

// Print the details
         }

   echo "\n</table>\n";


if($page != 1){
$pageprev = $page - 1;
echo("<a
href=\"$PHP_SELF?page=$pageprev&address_region=$address_region\">PREV</a>&nb
sp;");
}else
echo("PREV&nbsp;");
$numofpages = $totalrows / $limit;
for($i = 1; $i <= $numofpages; $i++){
if($i == $page)
echo($i."&nbsp;");
else
echo("<a
href=\"$PHP_SELF?page=$i&address_region=$address_region\">$i</a>&nbsp;");
}
if(($totalrows % $limit) != 1){
if($i == $page)
echo($i."&nbsp;");
}else
echo("<a
href=\"$PHP_SELF?page=$i&address_region=$address_region\">$i</a>&nbsp;");
if(($totalrows - ($limit * $page)) > 0){
$pagenext = $page + 1;
echo("<a
href=\"$PHP_SELF?page=$pagenext&address_region=$address_region\">NEXT</a>");
}else
echo("&nbsp; NEXT ");
mysql_free_result($result);


?>


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux