3dsmax
Member
سلام من یک برنامه دارم که با پی اچ پی سرچ می کنه و مطلب را پیدا می کنه ولی می خوام 3 تا دستور دیگه براش بزارم که هم هر یک از کلمات و کل کلمات و کل عبارت را سرچ کنه حالا می خوام ببینم چطور می شود این کار را کرد؟؟
ممنون می شوم اگه کمکم کنید!!
form.html
<form action = "search.php" method = "post">
<table border="0" cellpadding="0" cellspacing="0" align = "center">
<tr>
<td>
<b>Search Book</b>
<select name = "field">
<option value = "bookTitle"> By Title
<option value = "bookIsbn"> By ISBN
<option value = "bookAuthor"> By Author
</select>
<input type = "text" name = "query" size = "25" maxlength = "50" >
<input type="submit" value= " Search " name="submitButton">
</td>
</tr>
</table>
</form>
search.php
<?php>
$field = $_POST['field'];
$q = $_POST['query'];
$q = trim($q);
$db = mysql_connect('localhost','root','');
if(!$db)
{
echo "Cannot connect to MySQL";
exit;
}
if (!mysql_select_db('publisher'))
{
echo "cannot open bank" ;
exit;
}
switch($field)
{
case 'bookTitle' :
$query = "select * from books where title='$q'";
break;
case 'bookIsbn' :
$query = "select * from books where isbn = '$q'";
break;
default:
$query = "select * from books where author = '$q'";
}
$result = mysql_query("$query");
if(!$result)
{
echo " Cannot excute query.";
exit;
}
echo '<table border = "1" align = "center">';
echo "<tr>
<th> ISBN</th>
<th> Author</th>
<th> Title </th>
<th> Price </th>
<th> page </th>
</tr>";
$num = mysql_num_rows($result);
for($i = 0; $i < $num; $i ++)
{
$row = mysql_fetch_row($result);
echo '<tr>';
echo "<td><b> $row[0]</b> </td>";
echo "<td><b> $row[1]</b> </td>";
echo "<td><b> $row[2]</b> </td>";
echo "<td><b> $row[3]</b> </td>";
echo "<td><b> $row[4]</b> </td>";
echo '</tr>';
}
echo "<tr> <td><b> Number = $num </td></tr>";
echo "</table>";
mysql_close();
echo "<p></p>";
?>
ممنون می شوم اگه کمکم کنید!!
form.html
<form action = "search.php" method = "post">
<table border="0" cellpadding="0" cellspacing="0" align = "center">
<tr>
<td>
<b>Search Book</b>
<select name = "field">
<option value = "bookTitle"> By Title
<option value = "bookIsbn"> By ISBN
<option value = "bookAuthor"> By Author
</select>
<input type = "text" name = "query" size = "25" maxlength = "50" >
<input type="submit" value= " Search " name="submitButton">
</td>
</tr>
</table>
</form>
search.php
<?php>
$field = $_POST['field'];
$q = $_POST['query'];
$q = trim($q);
$db = mysql_connect('localhost','root','');
if(!$db)
{
echo "Cannot connect to MySQL";
exit;
}
if (!mysql_select_db('publisher'))
{
echo "cannot open bank" ;
exit;
}
switch($field)
{
case 'bookTitle' :
$query = "select * from books where title='$q'";
break;
case 'bookIsbn' :
$query = "select * from books where isbn = '$q'";
break;
default:
$query = "select * from books where author = '$q'";
}
$result = mysql_query("$query");
if(!$result)
{
echo " Cannot excute query.";
exit;
}
echo '<table border = "1" align = "center">';
echo "<tr>
<th> ISBN</th>
<th> Author</th>
<th> Title </th>
<th> Price </th>
<th> page </th>
</tr>";
$num = mysql_num_rows($result);
for($i = 0; $i < $num; $i ++)
{
$row = mysql_fetch_row($result);
echo '<tr>';
echo "<td><b> $row[0]</b> </td>";
echo "<td><b> $row[1]</b> </td>";
echo "<td><b> $row[2]</b> </td>";
echo "<td><b> $row[3]</b> </td>";
echo "<td><b> $row[4]</b> </td>";
echo '</tr>';
}
echo "<tr> <td><b> Number = $num </td></tr>";
echo "</table>";
mysql_close();
echo "<p></p>";
?>