Jump to content

Passing values using url Querystring


Willo009

Recommended Posts

Hi

        I have a problem i need some help with, when passing values from my Results page to my Details page through a URL is the Querystring different because i have INNER JOINED 2 tables? This is my Querystring

 

<a href="DetailsPet.php?id=<?php echo $row_ResultsRS['id']; ?>">Details</a></td>

 

i have 2 tables (petdata and customerdata) and there INNER JOINED using the 'id'

 

But its not passing on the values, and just shows the 1st results in database all the time. Im only just learning Php, but would i be right in thinking it to do with the 'id' as this is what joins the 2 tables. Do i have to state which 'id' to use? if so how do i do it?

 

Thanks willo

Link to comment
https://forums.phpfreaks.com/topic/226713-passing-values-using-url-querystring/
Share on other sites

Hi Rifts

          Thanks for your help on this, im very new to Php. Im unsure how too set the value to a Variable? could you show me an example. I have posted all the Php on my page below thanks

 

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

<?php

//WA Database Search Include

require_once("WADbSearch/HelperPHP.php");

?>

<?php

//WA Database Search (Copyright 2005, WebAssist.com)

//Recordset: ResultsRS;

//Searchpage: Index.php;

//Form: form1;

$WADbSearch1_DefaultWhere = "";

if (!session_id()) session_start();

if ((isset($_POST["WADbSearch1"])) && ($_POST["WADbSearch1"] != "")) {

  $WADbSearch1 = new FilterDef;

  $WADbSearch1->initializeQueryBuilder("MYSQL","1");

  //keyword array declarations

  $KeyArr0 = array("breed");

  $KeyArr1 = array("price");

  $KeyArr2 = array("city");

 

  //comparison list additions

  $WADbSearch1->addComparisonFromList("type","TypeSearch","AND","=",0);

  $WADbSearch1->keywordComparison($KeyArr0,"".((isset($_POST["breedSearch"]))?$_POST["breedSearch"]:"")  ."","AND","Includes",",%20","%20","%22","%22",0);

  $WADbSearch1->keywordComparison($KeyArr1,"".((isset($_POST["priceSearch"]))?$_POST["priceSearch"]:"")  ."","AND","Includes",",%20","%20","%22","%22",0);

  $WADbSearch1->addComparisonFromList("country","countrySearch","AND","=",0);

  $WADbSearch1->keywordComparison($KeyArr2,"".((isset($_POST["citySearch"]))?$_POST["citySearch"]:"")  ."","AND","Includes",",%20","%20","%22","%22",0);

 

  //save the query in a session variable

  if (1 == 1) {

    $_SESSION["WADbSearch1_ResultsPet"]=$WADbSearch1->whereClause;

  }

}

else    {

  $WADbSearch1 = new FilterDef;

  $WADbSearch1->initializeQueryBuilder("MYSQL","1");

  //get the filter definition from a session variable

  if (1 == 1)    {

    if (isset($_SESSION["WADbSearch1_ResultsPet"]) && $_SESSION["WADbSearch1_ResultsPet"] != "")    {

      $WADbSearch1->whereClause = $_SESSION["WADbSearch1_ResultsPet"];

    }

    else    {

      $WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;

    }

  }

  else    {

    $WADbSearch1->whereClause = $WADbSearch1_DefaultWhere;

  }

}

$WADbSearch1->whereClause = str_replace("\\''", "''", $WADbSearch1->whereClause);

$WADbSearch1whereClause = '';

?>

<?php

if (!function_exists("GetSQLValueString")) {

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")

{

  if (PHP_VERSION < 6) {

    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  }

 

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

 

  switch ($theType) {

    case "text":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;   

    case "long":

    case "int":

      $theValue = ($theValue != "") ? intval($theValue) : "NULL";

      break;

    case "double":

      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";

      break;

    case "date":

      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";

      break;

    case "defined":

      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;

      break;

  }

  return $theValue;

}

}

 

$maxRows_ResultsRS = 10;

$pageNum_ResultsRS = 0;

if (isset($_GET['pageNum_ResultsRS'])) {

  $pageNum_ResultsRS = $_GET['pageNum_ResultsRS'];

}

$startRow_ResultsRS = $pageNum_ResultsRS * $maxRows_ResultsRS;

 

$colname_ResultsRS = "-1";

if (isset($_GET['id'])) {

  $colname_ResultsRS = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);

}

mysql_select_db($database_petsCon, $petsCon);

$query_ResultsRS = sprintf("SELECT * FROM petdata INNER JOIN customerdata ON (petdata.id = customerdata.id) WHERE id = %s", GetSQLValueString($colname_ResultsRS, "int"));

setQueryBuilderSource($query_ResultsRS,$WADbSearch1,false);

$query_limit_ResultsRS = sprintf("%s LIMIT %d, %d", $query_ResultsRS, $startRow_ResultsRS, $maxRows_ResultsRS);

$ResultsRS = mysql_query($query_limit_ResultsRS, $petsCon) or die(mysql_error());

$row_ResultsRS = mysql_fetch_assoc($ResultsRS);

 

if (isset($_GET['totalRows_ResultsRS'])) {

  $totalRows_ResultsRS = $_GET['totalRows_ResultsRS'];

} else {

  $all_ResultsRS = mysql_query($query_ResultsRS);

  $totalRows_ResultsRS = mysql_num_rows($all_ResultsRS);

}

$totalPages_ResultsRS = ceil($totalRows_ResultsRS/$maxRows_ResultsRS)-1;

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.