SEARCHING PROBLEM....!!! HELP ME PLEASE

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
ashutosh
Forum Newbie
Posts: 3
Joined: Sun Feb 21, 2010 10:01 am

SEARCHING PROBLEM....!!! HELP ME PLEASE

Post by ashutosh »

Hi all,

I written the following code to search my DB. But the problem is I don't want to display this result. But by this result I am intersted to get the original result. That means how to search the DB again and again by a search result?? Is it possible??

Code: Select all

<?php
// Connect DB
include_once '../config/connection.php';
// Retrieve the SearchString
$q = mysql_real_escape_string($_POST["downline"]);
$newq = strtoupper($q);
//Run the search query
$searchQuery = mysql_query("SELECT * FROM `levelchart` WHERE UPPER(`userid`) LIKE
'%$newq%' ORDER BY `userid` DESC LIMIT 10");
while ($row =
mysql_fetch_assoc($searchQuery))
{
echo "<b>";
echo stripslashes($row["userid"]);
 
echo "</b><br />Name : ";
echo stripslashes($row['name']);
print "<br/>";
}
    
?>
<h4>LEVEL - 1</h4>
    <?php
    $search = mysql_query("SELECT * FROM `levelchart` WHERE UPPER(`intid`) LIKE
    '%$newq%' ORDER BY `level` DESC LIMIT 10");
    while ($row =
    mysql_fetch_assoc($search))
    {
    echo "<b><br />User ID : ";
    echo "</b>";
    echo stripslashes($row["userid"]);
    print ","."&nbsp";
    echo "<b>Name : ";
    echo "</b>";
    echo stripslashes($row['name']);
    $level1 = stripslashes($row["userid"]);
    }
    ?>
[b]<h4>LEVEL - 2</h4>[/b]
<?php
(I don't know how to do)    
    ?>
But this second result I want to display in this bolded tags of HTML
but want to search again for the same.

Thanks in advance.

-----
s.dot - Please use [ php ] and [ /php ] tags when posting PHP code.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Re: SEARCHING PROBLEM....!!! HELP ME PLEASE

Post by s.dot »

Is this some sort of downline table? Building downlines and hierarchical data can be very tricky.

I believe in the second query you want to search using the first query's $row['userid']. So in the second query you would replace WHERE '%$newq' with '%{$row['name']}%'.

This is definitely not an effective way of retreiving a downline, though. But it will work if you don't have many rows to search through repetitively.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply