Jump to content

Number of Filtered Results


justlukeyou

Recommended Posts

Hi,

 

The following code shows the "Find 20 Red Widgets".

 

Thats because I have a total of 20 Widgets in the database.  It supposed to show "Find 8 Red Widgets" because I have 8 "red" in the database.

 

I am using this code to show "Find 20 Widgets" but I cant get it to show "Find 8 Red Widgets"

 

Does anyone know how I can do this please?

 

Find <?php

$link = mysql_connect("localhost", "ukhomefu", "eggplummer123");
mysql_select_db("ukhomefu_eventvital", $link);

$result = mysql_query("SELECT * FROM hostdbase", $link);
$num_rows = mysql_num_rows($result);

echo "$num_rows \n";

?>
<?php
if (isset($_GET['linkcategory']))
{
    $linkcategory = mysql_real_escape_string($_GET['linkcategory']);
    $res = mysql_query("SELECT * FROM hostdbase WHERE linkcategory = '{$linkcategory}' ORDER BY category DESC LIMIT 1") or die(mysql_error());
    if($res && mysql_num_rows($res) > 0)
    {
        while($row = mysql_fetch_assoc($res))
        {

echo $row['category']; 

        }
    }
}
?>'s

Link to comment
Share on other sites

a) 'eggplumber123' is an awesome password.  hope that's fake.

 

b) if you're querying for all the rows, why are you querying a second time? 

 

since you have already have the full query (for whatever reason), why don't you compare the $result array's key for the same query string?

Link to comment
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.