Skip to main content
Inspiring
January 23, 2012
Answered

tried Build a basic results page on the dreamwever page but no luck

  • January 23, 2012
  • 1 reply
  • 973 views

Hi

I followed the guide on http://help.adobe.com/en_US/dreamweaver/cs/using/WScbb6b82af5544594822510a94ae8d65-78ada.html

and i run a test on the SIMPLE recordset query and it produced the correct information, i then created a dynamic table and uploaded the search result page and the search form, when i run the search page with a search i know will produce a result it comes back blank

the code is below

search results page

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

<?

          session_start();

          if(!$_SESSION['loggedIn']) // If the user IS NOT logged in, forward them back to the login page

          {

                    header("location:Login.html");

          }

?>

<?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_Recordset1 = 10;

$pageNum_Recordset1 = 0;

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

  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];

}

$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

$colname_Recordset1 = "-1";

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

  $colname_Recordset1 = $_GET['userid'];

}

mysql_select_db($database_hostprop, $hostprop);

$query_Recordset1 = sprintf("SELECT userid, email, name, prop_id FROM plus_signup WHERE userid = %s", GetSQLValueString($colname_Recordset1, "text"));

$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);

$Recordset1 = mysql_query($query_limit_Recordset1, $hostprop) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

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

  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];

} else {

  $all_Recordset1 = mysql_query($query_Recordset1);

  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);

}

$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

?>

THE TABLE FOR THE RESULTS IS BELOW

<table width="800" border="1" class="table-text">

            <tr class="table-text">

              <td>userid</td>

              <td>email</td>

              <td>name</td>

              <td>prop_id</td>

            </tr>

            <?php do { ?>

              <tr>

                <td class="table-text"><?php echo $row_Recordset1['userid']; ?></td>

                <td class="table-text"><?php echo $row_Recordset1['email']; ?></td>

                <td class="table-text"><?php echo $row_Recordset1['name']; ?></td>

                <td class="table-text"><?php echo $row_Recordset1['prop_id']; ?></td>

              </tr>

              <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>

          </table>

This topic has been closed for replies.
Correct answer bregent

the form code now looks like this

<form id="form1" name="form1" method="post" action="../hostadmin/searchresults.php">

          <label for="userid"></label>

          <table width="363" border="0" cellspacing="0" cellpadding="0">

            <tr>

              <td><input name="userid" type="text" id="userid" size="38" /></td>

              <td><input type="image" src="../images/searchbutton3.gif" name="userid" id="userid" value="submit

              " /></td>

            </tr>

          </table>

        </form>

and the php lookks like this

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

<?

          session_start();

          if(!$_SESSION['loggedIn']) // If the user IS NOT logged in, forward them back to the login page

          {

                    header("location:Login.html");

          }

?>

<?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_Recordset1 = 10;

$pageNum_Recordset1 = 0;

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

  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];

}

$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

$colname_Recordset1 = "-1";

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

  $colname_Recordset1 = $_GET['userid'];

}

mysql_select_db($database_hostprop, $hostprop);

$query_Recordset1 = sprintf("SELECT userid, email, name, prop_id FROM plus_signup WHERE userid = %s", GetSQLValueString($colname_Recordset1, "text"));

$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);

$Recordset1 = mysql_query($query_limit_Recordset1, $hostprop) or die(mysql_error());

$row_Recordset1 = mysql_fetch_assoc($Recordset1);

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

  $totalRows_Recordset1 = $_GET['totalRows_Recordset1'];

} else {

  $all_Recordset1 = mysql_query($query_Recordset1);

  $totalRows_Recordset1 = mysql_num_rows($all_Recordset1);

}

$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;

?>

and it is still returning no results.

should the url parameter be passed or form variable as it coming from a form?




You changed both the user input text field and the submit button name to "userid" so of course it's not going to work. Item's are passed in the querystring by name, so you can't have two items with the same name. Change the submit button back the way it was.

EDIT: I also see that you are using POST on your form, but GET in your script. You need to pick one or the other. If you are displaying senstive data, which it seems you are, then you must use POST.

1 reply

Participating Frequently
January 23, 2012

Please post the form code.

Inspiring
January 24, 2012

<form id="form1" name="form1" method="post" action="../admin/searchresults.php">

          <label for="search"></label>

          <table width="363" border="0" cellspacing="0" cellpadding="0">

            <tr>

              <td><input name="search" type="text" id="search" size="38" /></td>

              <td><input type="image" src="../images/searchbutton3.gif" name="search" id="search" value="submit

              " /></td>

            </tr>

          </table>

        </form>

i am using an image for the search button instead of the standard icon

Participating Frequently
January 24, 2012

Your form is sending a field named "search" but your script is looking for a field called "userid". You'll need to change one or the other.