Jump to content

[SOLVED] search clause help


AcidDriver

Recommended Posts

I have one more thing...

 

<?php

 

//Displays once search text is run through.

if ($_POST['searching'] =="yes")

{

echo "<h1>Your results: </h1><p>";

 

//If nothing is entered then return no search text.

if ($_POST['find'] == "")

{

echo "<p>Please enter a search item in the query box</";

exit;

}

 

// Else, connect direct to the database

mysql_connect("localhost", "root", "") or die(mysql_error()); //Need to setup dedicated H.O.P.E server to link to mySQL, then input user/server info.

mysql_select_db("hope") or die(mysql_error());

 

 

//Search for search term once in database.

$data = mysql_query("SELECT * FROM hope WHERE upper('$field') LIKE '%$find%'");

 

 

I get this notice...

 

Notice: Undefined variable: field in H:\Documents\My Web Sites\HOPE Search Database\search.php on line 21

 

Notice: Undefined variable: find in H:\Documents\My Web Sites\HOPE Search Database\search.php on line 21

mike ronzetti

they are defined in the index.html file.

 

<html>

 

<head>

<title>Welcome to the HOPE Database</title>

<link rel="stylesheet" href="text/main.css" type="text/css" />

</head>

 

<body>

<h1>H.O.P.E Volunteer Database Search</h1>

<font class="title">Please enter your database query below.</font>

<form name="search" method="post" action="search.php">

Search: <input type="text" value="find" name="find" /> Category: 

<Select NAME="field">

<Option value="fname">First Name</option><!--Searches according to the volunteers last name -->

<Option value="lname">Last Name</option><!--Searches according to the volunteers first name -->

<Option value="idnum">ID Number</option><!--Searches according to the volunteers ID Number -->

<option value="gradyear">Graduation Year</option>

</Select><br>

<input type="hidden" name="searching" value="yes" />

<input type="submit" name="search" value="Search Database" class="note"/>

</form>

<br>

<br>

<a href="volunteer.htm">Input a new volunteer</a>

</body>

</html>

 

herer is the search again

 

<?php

 

//Displays once search text is run through.

if ($_POST['searching'] =="yes")

{

echo "<h1>Your results: </h1><p>";

 

//If nothing is entered then return no search text.

if ($_POST['find'] == "")

{

echo "<p>Please enter a search item in the query box</";

exit;

}

 

// Else, connect direct to the database

mysql_connect("localhost", "root", "") or die(mysql_error()); //Need to setup dedicated H.O.P.E server to link to mySQL, then input user/server info.

mysql_select_db("hope") or die(mysql_error());

 

 

//Search for search term once in database.

$data = mysql_query("SELECT * FROM hope WHERE upper('$field') LIKE '%$find%'");

 

//Display results

while($result = mysql_fetch_array( $data ))

{

echo "<u><b>";

echo $result['fname'];

echo " ";

echo $result['lname'];

echo "</b></u><b><br>ID Number:</b> ";

echo $result['idnum'];

echo "<b><br>Graduation Year:</b> ";

echo $result['gradyear'];

//echo "<b><br>Donor:</b> ";

//echo $result['donor'];

//echo "<br><b>FOH/Community Partner:</b> ";

//echo $result['foh'];

echo "<br><b>Organization/Firm: </b>";

echo $result['org'];

//echo "<br><b>HOPE Fellow:</b> ";

//echo $result['fellow'];

//echo "<br><b>HOPE Senior Fellow:</b> ";

//echo $result['sfellow'];

//echo "<br><b>Miami Scholar: </b>";

//echo $result['scholar'];

//echo "<br><b>Public Interest Loan Reduction Recipient:</b> ";

//echo $result['lreduce'];

echo "<br><b><br>Home Address:</b>";

echo $result['address'];

echo "<br>";

echo $result['city'] .", " .$result['state'] ." " .$result['zip'];

echo "<br><b><br>Work Address:</b> <br>";

echo $result['waddress'];

echo "<br>";

echo $result['wcity'] .", " .$result['wstate'] ." " .$result['wzip'];

echo "<br><b>Work Phone:</b>";

echo $result['wphone'];

echo "<br><b>Fax number: </b>";

echo $result['fax'];

echo "<br><b>Cell Phone: </b>";

echo $result['cphone'];

echo "<br><b>Email:</b>";

echo $result['email'];

//echo "<br><b><br>Interests:</b> ";

//echo $result['Interests'];

//echo "<br><b>Project Leader: </b>";

//echo $result['project'];

//echo "<br><b>HOPE Liason:</b> ";

//echo $result['liason'];

//echo "<br><b>Center for Ethics and Public Service Liason:</b> ";

//echo $result['pliason'];

echo "<br><br><b>Community Service Hours:</b>";

echo $result['comtotalhours'];

echo "<br><dd><b>Project Name/Agency: </b></dd>";

echo $result['comagency'];

echo "<br><dd><b>Date of Project: </dd></b>";

echo $result['comdate'];

echo "<br><dd><b>Community Service Project Hours: </b></dd>";

echo $result['comhours'];

echo "<br><br><b>Advocacy Service Hours: </b>";

echo $result['adtotalhours'];

echo "<br><dd><b>Project Name/Agency: </b></dd>";

echo $result['adagency'];

echo "<br><dd><b>Date of Project: </dd></b>";

echo $result['addate'];

echo "<br><dd><b>Hours Volunteered: </b></dd>";

echo $result['adhours'];

echo "<br><dd><b>Supervising Attorney: </b></dd>";

echo $result['adattorney'];

echo "<br><dd><b>Attorney Contact: </b></dd>";

echo $result['adattorneycon'];

//echo "<br><b><br>Languages: </b>";

//echo $result['languages'];

echo "<br><br><br><br><br>";

}

 

//This counts the number or results - and if there wasn't any it gives them a little message explaining that

$matchnum=mysql_num_rows($data);

if ($matchnum == 0)

{

echo "There were no results for you mySQL query.<br><br>";

}

 

//Echo back what the user searched for:

echo "<b>Searched For: </b> " .$find;

echo "<b>Number of Results: </b> " .$matchnum;

echo "<br>";

echo '<a href="http://127.0.0.1/HOPE%20Database/index.htm">Search Again</a>';

}

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.