Help with my search page plz !

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sinajoon
Forum Newbie
Posts: 1
Joined: Thu Jan 14, 2010 12:50 pm

Help with my search page plz !

Post by sinajoon »

Hi evrey one .

im new in this froum and im going to leaning php so well

so i make a search page for my projects that its code is here :

Code: Select all

<?php require_once('Connections/database.php'); ?>
<?php $name = $_POST["name"];?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $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;
}
}
 
$currentPage = $_SERVER["PHP_SELF"];
 
$maxRows_Recordset1 = 10;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
  $pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;
 
mysql_select_db($database_database, $database);
$query_Recordset1 = "SELECT * FROM `database` WHERE `database`.name LIKE '%$name%'";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $database) 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;
 
$queryString_Recordset1 = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_Recordset1") == false && 
        stristr($param, "totalRows_Recordset1") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_Recordset1 = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_Recordset1 = sprintf("&totalRows_Recordset1=%d%s", $totalRows_Recordset1, $queryString_Recordset1);
 
mysql_free_result($Recordset1);
?>
 
<?php echo $totalRows_Recordset1 ?>
<p>&nbsp;</p>
 
<table border="1">
  <tr>
    <td>fabrik_internal_id</td>
    <td>time_date</td>
    <td>name</td>
    <td>code</td>
    <td>tedad</td>
    <td>remarks</td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_Recordset1['fabrik_internal_id']; ?></td>
      <td><?php echo $row_Recordset1['time_date']; ?></td>
      <td><?php echo $row_Recordset1['name']; ?></td>
      <td><?php echo $row_Recordset1['code']; ?></td>
      <td><?php echo $row_Recordset1['tedad']; ?></td>
      <td><?php echo $row_Recordset1['remarks']; ?></td>
    </tr>
    <?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
 
Records <?php echo ($startRow_Recordset1 + 1) ?> to <?php echo min($startRow_Recordset1 + $maxRows_Recordset1, $totalRows_Recordset1) ?> of <?php echo $totalRows_Recordset1 ?>
<p>
every thing is ok but the problem is that the dynamic table which show the recordsets from search key word is only one item that it should be 10 !!

so what i should i do ?
thanks alot
Last edited by califdon on Thu Jan 14, 2010 9:44 pm, edited 1 time in total.
Reason: Changed Code tag from "text" to "php" to highlight syntax.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Re: Help with my search page plz !

Post by califdon »

After line 40 (in the listing above), try echoing out the value of $startRow_Recordset1.
Post Reply