Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Search form

$
0
0

Can someone maybe help me. I am new to php mysql and I am trying to create a search form where a user type in a name and the record of that name is displayed. Here is the error I get:  Undefined variable: cname in C:\wamp\www\whodidntpay\search.php on line 32.

 

Here is my code:

<html>

<head>Search</title>
</head>
<p>
Company Name: <input type=text name=cname size=50 maxlength=50>
<p>
<input type=submit>
<body>

<table width="600" border="1" cellpadding="1" cellspacing="1">
<tr>

<th>Company Name</th>
<th>Reg</th>
<th>Email</th>
<th>Per</th>
<th>Num</th>
<th>NotPaid</th>
<th>Amount</th>
<tr>

<?php

mysql_connect('localhost', 'root', '');

mysql_select_db('whodidntpay');

// if ($cname == "")
//{$cname = '%';}

$sql="SELECT * FROM debtor WHERE cname LIKE '$cname%'";

$records=mysql_query($sql);

?>	

while ($debtor=mysql_fetch_assoc($records))
{
	echo "<tr>";
	
	echo "<td>".$debtor['d_name']."</td>";
	
	echo "<td>".$debtor['registration_nr']."</td>";
	
	echo "<td>".$debtor['email']."</td>";
	
	echo "<td>".$debtor['contact_person']."</td>";
	
	echo "<td>".$debtor['contact_number']."</td>";
	
	echo "<td>".$debtor['companies_not_paid']."</td>";
	
	echo "<td>".$debtor['amount_not_paid']."</td>";
	
}

</html>	

Thank you


Viewing all articles
Browse latest Browse all 13200

Trending Articles