Jump to content

Recommended Posts

      <? 
if (count ($totalRows_search) > 0)
echo("No results found matching your query - $query"); 
  ?>

 

what is wrong .. i whant show this message (No results found matching your query) if my search find 0 results from mysql

 

but show this message only if find nothink

i don't whant see the message in first page ..

 

Link to comment
https://forums.phpfreaks.com/topic/163245-count-help/
Share on other sites

thank you for you help and im sorry

 

<?php

if (count ($totalRows_search) == 0)
echo("No results found matching your query - $query");
?>

 

look what i whant i got this

mysql_select_db($database_files, $files);
$query_search = sprintf("SELECT * FROM crackz WHERE `option` = 'yes' and type = '$type' and name LIKE %s ORDER BY `date` DESC", GetSQLValueString("%" . $colname_search . "%", "text"));
get_error($results);
$query_limit_search = sprintf("%s LIMIT %d, %d", $query_search, $startRow_search, $maxRows_search);
$search = mysql_query($query_limit_search, $files) or die(mysql_error());
$row_search = mysql_fetch_assoc($search);

 

i just whant if $totalRows_search is nothink get this error "No results found matching your query - $query"

how i can?

im trying maybe cont its not right way ..

 

Link to comment
https://forums.phpfreaks.com/topic/163245-count-help/#findComment-861433
Share on other sites

@947740

 

<?php

if (count ($totalRows_search) == 0)
echo("No results found matching your query - $query");
?>

 

There is noting 'screwed up' with that if statement...

 

http://us3.php.net/manual/en/control-structures.if.php

 

Check out the first example. If the statment only executes a single line of code it does not require the curly brackets to enclose the resulting code.

 

Though your fix does have an error;

 

<?php

if (count ($totalRows_search) == 0)) {
echo("No results found matching your query - $query");
}
?>

 

You have one to many closing brackets at the end of the conditional statement

 

@ctcp

 

Can you show all your code?

Link to comment
https://forums.phpfreaks.com/topic/163245-count-help/#findComment-861566
Share on other sites

<?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;
}
}

$currentPage = $_SERVER["PHP_SELF"];

$maxRows_search = 50;
$pageNum_search = 0;
if (isset($_GET['pageNum_search'])) {
  $pageNum_search = $_GET['pageNum_search'];
}
$startRow_search = $pageNum_search * $maxRows_search;

$colname_search = "-1";
if (isset($_GET['query'])) {
  $colname_search = $_GET['query'];
}
mysql_select_db($database_files, $files);
$query_search = sprintf("SELECT * FROM crackz WHERE `option` = 'yes' and type = '$type' and name LIKE %s ORDER BY `date` DESC", GetSQLValueString("%" . $colname_search . "%", "text"));
$query_limit_search = sprintf("%s LIMIT %d, %d", $query_search, $startRow_search, $maxRows_search);
$search = mysql_query($query_limit_search, $files) or die(mysql_error());
$row_search = mysql_fetch_assoc($search);

if (isset($_GET['totalRows_search'])) {
  $totalRows_search = $_GET['totalRows_search'];
} else {
  $all_search = mysql_query($query_search);
  $totalRows_search = mysql_num_rows($all_search);
}
$totalPages_search = ceil($totalRows_search/$maxRows_search)-1;

$maxRows_numbs = 50;
$pageNum_numbs = 0;
if (isset($_GET['pageNum_numbs'])) {
  $pageNum_numbs = $_GET['pageNum_numbs'];
}
$startRow_numbs = $pageNum_numbs * $maxRows_numbs;

mysql_select_db($database_files, $files);
$query_numbs = "select * from crackz where `option` = 'Yes' and  name like '".chr($numbs)."%' order by name";
$query_limit_numbs = sprintf("%s LIMIT %d, %d", $query_numbs, $startRow_numbs, $maxRows_numbs);
$numbs = mysql_query($query_limit_numbs, $files) or die(mysql_error());
$row_numbs = mysql_fetch_assoc($numbs);

if (isset($_GET['totalRows_numbs'])) {
  $totalRows_numbs = $_GET['totalRows_numbs'];
} else {
  $all_numbs = mysql_query($query_numbs);
  $totalRows_numbs = mysql_num_rows($all_numbs);
}
$totalPages_numbs = ceil($totalRows_numbs/$maxRows_numbs)-1;

$colname_ids = "-1";
if (isset($_GET['recordID'])) {
  $colname_ids = $_GET['recordID'];
}
mysql_select_db($database_files, $files);
$query_ids = sprintf("SELECT * FROM crackz WHERE `option` = 'Yes' and id = %s", GetSQLValueString($colname_ids, "int"));
$ids = mysql_query($query_ids, $files) or die(mysql_error());
$row_ids = mysql_fetch_assoc($ids);
$totalRows_ids = mysql_num_rows($ids);

mysql_select_db($database_files, $files);
$query_Recordset1 = "SELECT * FROM crackz";
$Recordset1 = mysql_query($query_Recordset1, $files) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);
$totalRows_Recordset1 = mysql_num_rows($Recordset1);

$queryString_search = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_search") == false && 
        stristr($param, "totalRows_search") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_search = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_search = sprintf("&totalRows_search=%d%s", $totalRows_search, $queryString_search);

$queryString_numbs = "";
if (!empty($_SERVER['QUERY_STRING'])) {
  $params = explode("&", $_SERVER['QUERY_STRING']);
  $newParams = array();
  foreach ($params as $param) {
    if (stristr($param, "pageNum_numbs") == false && 
        stristr($param, "totalRows_numbs") == false) {
      array_push($newParams, $param);
    }
  }
  if (count($newParams) != 0) {
    $queryString_numbs = "&" . htmlentities(implode("&", $newParams));
  }
}
$queryString_numbs = sprintf("&totalRows_numbs=%d%s", $totalRows_numbs, $queryString_numbs);
?>

<form id="form2" name="form2" method="get" action="">
  <label for=""></label>
<input id="boxy" type="text" name="query" value="<? if (isset($query)) echo $query; ?>"/>
  <label for="type"></label>
  <select name="type" id="type">
    <option value="Games">Games</option>
    <option value="Apps">Apps</option>
    <option value="TV">TV</option>
    <option value="Movies">Movies</option>
    <option value="Music">Music</option>
    <option value="eBooks">eBooks</option>
    <option value="Porn">Porn</option>
    <option value="Other">Other</option>
  </select>
  <label for="search"></label>
<button type="submit">Search</button>    <? if (isset($query)) { ?>
LinksCopy Search results for [<strong><? echo $query; ?></strong>]
<? } ?>
[ Online [<font color="#FF0000"> <?php echo $totalRows_Recordset1 ?></font> ] Records ]
</form>
<form id="form1" name="form1" method="post" action="">
<div class="secondlevel">
<ul>
<li><a href="?section=view">0-9</a>
<? for ($id=65; $id < 91; $id++) { ?>
<li <? if ($id == $numbs) { echo 'class="current"'; } ?>><a href="?section=<? echo $section; ?>&numbs=<? echo $id; ?>"><? echo chr($id); ?></a></li>
<? } ?></ul></div>
<?php if ($totalRows_search > 0) { // Show if recordset not empty ?>
  <?php do { ?>
      <tr>
      <li> [<?php echo $row_search['type']; ?>] - [<?php echo $row_search['date']; ?>] - <a href="?recordID=<?php echo $row_search['id']; ?>"> <?php echo $row_search['name']; ?></a></li>
    </tr>
    <?php } while ($row_search = mysql_fetch_assoc($search)); ?>
  <?php } // Show if recordset not empty ?>
<tr>
  <?php if ($totalRows_numbs > 0) { // Show if recordset not empty ?>
    <?php do { ?>
      <li> [<?php echo $row_numbs['type']; ?>] - [<?php echo $row_numbs['date']; ?>] - <a href="?recordID=<?php echo $row_numbs['id']; ?>"> <?php echo $row_numbs['name']; ?></a><br />
      </li>
      <?php } while ($row_numbs = mysql_fetch_assoc($numbs)); ?>
    <?php } // Show if recordset not empty ?>
</tr>
</form>
<?php if ($totalRows_ids > 0) { // Show if recordset not empty ?>
  <table width="100%" border="0" align="center">
    <tr>
      <th width="9%" align="left" valign="top" scope="col">Name</th>
      <td width="59%" align="left" valign="top" scope="col"><?php echo $row_ids['name']; ?></td>
      <th width="32%" rowspan="10" align="center" valign="top" scope="col">
<?
$URL_parts = @parse_url ($row_ids['site_url']);
$DOMAIN = str_ireplace ("www.", "", $URL_parts['host']);
?>
<a href="<?php echo $row_ids['site_url']; ?>"target="_blank"><img src="image/site/<?if ( @is_file ("image/site/".$DOMAIN.".jpg" ) ){ echo $DOMAIN.".jpg"; }else{ echo "linkscopy.jpg"; }?>" alt="" width="270" height="173" /></a>
</p>
      </a></p></th>
      </tr>
    <tr>
      <th colspan="2" align="left" valign="top" scope="col"><hr /></th>
      </tr>
    <tr>
      <th align="left" valign="top" scope="col">Type</th>
      <td align="left" valign="top" scope="col"><?php echo $row_ids['type']; ?></td>
      </tr>
    <tr>
      <th colspan="2" align="left" valign="top"><hr /></th>
      </tr>
    <tr>
      <th align="left" valign="top">Date</th>
      <td align="left" valign="top"><?php echo $row_ids['date']; ?></td>
      </tr>
    <tr>
      <th colspan="2" align="left" valign="top"><hr /></th>
      </tr>
    <tr>
      <th align="left" valign="top">Password</th>
      <td align="left" valign="top"><?php echo $row_ids['pack_password']; ?></td>
      </tr>
    <tr>
      <th colspan="2" align="left" valign="top"><hr /></th>
      </tr>
    <tr>
      <th align="left" valign="top">Site Url</th>
      <td align="left" valign="top"><a href="<?php echo $row_ids['site_url']; ?>"target="_blank"><?php echo $row_ids['site_url']; ?></a></td>
      </tr>
    <tr>
      <th align="left" valign="top">Links</th>
      <td><form action="http://tubenow.net/link-checker/" method="post" target="_blank">
        <textarea style="border: 1px solid #9d9d9d; background-color: #f8f0e0; color: #000;" rows="30" cols="100" name="links"><?php echo $row_ids['links']; ?>
        </textarea>
        <div style="margin-top:4px;">
          <input style="padding: 2px;" type="submit" value="Check Links" name="submit" />
          </div>
  </form></td>
      </tr>
    <tr>
      <td> </td>
      <td> </td>
      <td> </td>
      </tr>
    </table>
  <?php } // Show if recordset not empty ?>
<table width="80%" border="0">
    <tr><th align="left" scope="col">
  <?php if ($totalRows_search > 0) { // Show if recordset not empty ?>
    Result <?php echo ($startRow_search + 1) ?> to <?php echo min($startRow_search + $maxRows_search, $totalRows_search) ?> of <?php echo $totalRows_search ?><br />
<?php } // Show if recordset not empty ?>
  <?php if ($totalRows_numbs > 0) { // Show if recordset not empty ?>
    Result <?php echo ($startRow_numbs + 1) ?> to <?php echo min($startRow_numbs + $maxRows_numbs, $totalRows_numbs) ?> of <?php echo $totalRows_numbs ?>
  <?php } // Show if recordset not empty ?>
  <br /></th>
    </tr>
</table>
  
  <table width="20%" border="0" align="left">
  <?php if ($totalRows_numbs > 0) { // Show if recordset not empty ?>
    <tr>
      <td width="43%" align="center" valign="top" scope="col"><a href="<?php printf("%s?pageNum_numbs=%d%s", $currentPage, max(0, $pageNum_numbs - 1), $queryString_numbs); ?>"><<Back</a></td>
      <td width="57%" align="center" scope="col"><a href="<?php printf("%s?pageNum_numbs=%d%s", $currentPage, min($totalPages_numbs, $pageNum_numbs + 1), $queryString_numbs); ?>">Next>></a></td>
    </tr>
    <?php } // Show if recordset not empty ?>
</table>
<table width="20%" border="0" align="left">
    <tr align="center">
      <td width="76"><?php if ($pageNum_search > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_search=%d%s", $currentPage, 0, $queryString_search); ?>">First</a>
          <?php } // Show if not first page ?></td>
      <td width="125"><?php if ($pageNum_search > 0) { // Show if not first page ?>
          <a href="<?php printf("%s?pageNum_search=%d%s", $currentPage, max(0, $pageNum_search - 1), $queryString_search); ?>"><<Back</a>
      <?php } // Show if not first page ?></td>
      <td width="111"><?php if ($pageNum_search < $totalPages_search) { // Show if not last page ?>
          <a href="<?php printf("%s?pageNum_search=%d%s", $currentPage, min($totalPages_search, $pageNum_search + 1), $queryString_search); ?>">Next></a><a href="<?php printf("%s?pageNum_search=%d%s", $currentPage, min($totalPages_search, $pageNum_search + 1), $queryString_search); ?>">></a>
          <?php } // Show if not last page ?></td>
      <td width="168"><?php if ($pageNum_search < $totalPages_search) { // Show if not last page ?>
          <a href="<?php printf("%s?pageNum_search=%d%s", $currentPage, $totalPages_search, $queryString_search); ?>">Last</a>
          <?php } // Show if not last page ?></td>
    </tr>
</table>
<p>
<?php
mysql_free_result($search);

mysql_free_result($numbs);

mysql_free_result($ids);

mysql_free_result($Recordset1);
?>

 

i whana make if search is null

show error message .. thank you ..

 

Link to comment
https://forums.phpfreaks.com/topic/163245-count-help/#findComment-862283
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.