Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-20-2012, 01:02 AM   PM User | #1
softpk
New to the CF scene

 
Join Date: Feb 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
softpk is an unknown quantity at this point
Unhappy How to search multiple field please help me

hello sir,

please help how to search multiple field i am trying but show this error

Found:
Fatal error: Call to a member function free() on a non-object in G:\WampDeveloper\Websites\DefaultWebsite\webroot\test2\search.php on line 59


My Code:

<?php
/*set varibles from form */
$searchterm = $_POST['searchterm'];
trim ($searchterm);
/*check if search term was entered*/
if (!$searchterm){
echo 'Please enter a search term.';
}
/*add slashes to search term*/
if (!get_magic_quotes_gpc())
{
$searchterm = addslashes($searchterm);
}

/* connects to database */
@ $dbconn = new mysqli('localhost', 'username', 'password', 'database');
if (mysqli_connect_errno())
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
/*query the database*/
$query = "select * from splist where partcatno,costprice like '%".$searchterm."%'";
$result = $dbconn->query($query);
/*number of rows found*/
$num_results = $result->num_rows;

echo '<p>Found: '.$num_results.'</p>';
/*loops through results*/
for ($i=0; $i <$num_results; $i++)
{
$num_found = $i + 1;
while ($row = $result->fetch_object())
if ($result->num_rows > 0)
{
echo "<table border='1' cellpadding='10'>";
echo "<tr><th>ID</th><th>Description</th><th>Part/Cat No</th><th>Total Quantity</th><th>Balance</th><th>Cost Price</th><th>Sales Price</th><th>Remarks</th><th></th><th></th></tr>";

{
// set up a row for each record
echo "<tr>";
echo "<td>" . $row->idd . "</td>";
echo "<td>" . $row->despspl . "</td>";
echo "<td>" . $row->partcatno . "</td>";
echo "<td>" . $row->totalquantity . "</td>";
echo "<td>" . $row->balance . "</td>";
echo "<td>" . $row->costprice . "</td>";
echo "<td>" . $row->salesprice . "</td>";
echo "<td>" . $row->remarks . "</td>";
echo "<td><a href='records.php?idd=" . $row->idd . "'>Edit</a></td>";
echo "<td><a href='delete.php?idd=" . $row->idd . "'>Delete</a></td>";
echo "</tr>";
}

echo "</table>";
}
}
/*free database*/
$result->free();
$dbconn->close();
?>
softpk is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:45 AM.


Advertisement
Log in to turn off these ads.