Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Beginning PHP
|
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 9th, 2007, 05:05 AM
Registered User
 
Join Date: Oct 2007
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Urgently Need Help

Dear All,

i want to make advance search engine in PHP.i have 7 fields and all fields are option.if user select only 4 filed,then search engine will display the result according to 4 selected field.?

how to do it ? if anybody have any idea or document or book or article please share with me? its very urgent.

thanks to all in advance

humayoo
 
Old October 10th, 2007, 12:54 AM
Authorized User
 
Join Date: Mar 2005
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to cyber_kaley20 Send a message via AIM to cyber_kaley20 Send a message via Yahoo to cyber_kaley20
Default

check box
//////////
data1
data2
data3
data4
data5
data6
data7
///////
search mytextbox >>>>


im going to select a 7 fields

$sql = "SELECT * FROM articles WHERE


if (data1 = "checkbox") //////find the data with selected
     {
          $sql .= "data1 LIKE '$mysearchtext'";/////// if the data1

                                                //////it selected
      }
if ($data2 = "checkbox")
      {
    $sql .= "data2 LIKE '$mysearchtext'";
       }
if($data3 ="checkbox")
     {
        $sql .= "data3 LIKE '$mysearchtext'";
     }
if($data4 = "checkbox")
     {
     $sql .= "data4 LIKE '$mysearchtext'";
     }

if($data5 = "checkbox")
     {
     $sql .= "data5 LIKE '$mysearchtext'";
     }


if($data6 = "checkbox")
     {
     $sql .= "data6 LIKE '$mysearchtext'";
     }

if($data7 = "checkbox")
     {
    $sql .= "data7 LIKE '$mysearchtext'";
     }




$query = mysql_query($sql) or die(mysql_error());
$row_sql = mysql_fetch_assoc($query);
$total = mysql_num_rows($query);


# if($total>0) {
# while ($row_sql = mysql_fetch_assoc($query)) {//echo out the results
# echo ''.$row_sql['title'].'<br />'.$row_sql['subtitle'].'';
# }
# } else
# {
# echo "No results to display";
# }


Escaler
 
Old October 16th, 2007, 02:39 PM
Registered User
 
Join Date: Aug 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello
Maybe you can use this Example

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<?Php
    extract($_GET);
    extract($_POST);
    $Sql= "Select * FROM MyTable WHERE ";
    if (isset($textfield1))
        $Sql.="MyTable.field1 = $textfield1 AND ";

    if (isset($textfield2))
        $Sql.="MyTable.field2 = $textfield2 AND ";

    if (isset($textfield3))
        $Sql.="MyTable.field3 = $textfield3 AND ";

    if (isset($textfield4))
        $Sql.="MyTable.field4 = $textfield4 AND ";

    if (isset($textfield5))
        $Sql.="MyTable.field5 = $textfield5 AND ";

    if (isset($textfield6))
        $Sql.="MyTable.field6 = $textfield6 AND ";

    if (isset($textfield7))
        $Sql.="MyTable.field7 = $textfield7 AND ";

        //You can change the WHERE part as you wish, in order to do what you want

    //$Rs = mysql_query($Sql);
    /*
    .Do everything you need with the RecordSet Rs
    .
    .
    etc*/
    echo $Sql;
?>
<body>
<p>Seach Filter:</p>
<FORM ENCTYPE="multipart/form-data" id="form1" name="form1" method="post" action="Prueba.php">
    <table border="1" width="100%">
        <tr>
            <th>textfield1</th>
            <th>textfield2</th>
            <th>textfield3</th>
            <th>textfield4</th>
        </tr>
        <tr>
            <td>
                <input type="text" name="textfield1" />
            </td>
            <td>
                <input type="text" name="textfield2" />
            </td>
            <td>
                <input type="text" name="textfield3" />
            </td>
            <td>
                <input type="text" name="textfield4" />
            </td>
        </tr>
    </table>
    <br/>
    <table border="1" width="100%">
        <tr>
            <th>textfield5</th>
            <th>textfield6</th>
            <th>textfield7</th>
        </tr>
        <tr>
            <td>
                <input type="text" name="textfield5" />
            </td>
            <td>
                <input type="text" name="textfield6" />
            </td>
            <td>
                <input type="text" name="textfield7" />
            </td>
        </tr>
    </table>
    <input name="Agregar" type="submit" />
</form>
</body>
</html>

Ludigova






Similar Threads
Thread Thread Starter Forum Replies Last Post
JMeter: Need help Urgently motionless BOOK: Expert One-on-One J2EE Design and Development 0 February 19th, 2008 12:16 PM
Need Help Urgently dpkbahuguna Beginning VB 6 2 August 10th, 2006 01:29 AM
urgently need help sumeghagupta .NET Web Services 1 October 5th, 2004 11:38 PM
Urgently need help... scott Access 23 October 18th, 2003 09:40 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.