Jump to content

search term corresponds with radio button selected


phpabcd

Recommended Posts

I want to let user to choose the checked box, so they will type in the words in the box, and select the radio button to limit their search. How should I approach it?

 

$search_words = mysql_real_escape_string($_POST['search_words']);

 

$query =

"SELECT name,login_id,password,email

FROM User

WHERE name LIKE '".$search_words."%'

ORDER BY name ASC";

// my query to display the necessary fields

$result = mysql_query($query, $conn);//get results

$result2 = mysql_query($query, $conn);//get results

$resultCheck = mysql_result($result2,0,0);

?>

       

<p align="center" class="passwordsummary_header"> User's Password Summary

<table width="302" border="1" align="center">

  <tr>

    <td width="229">

    <form method="post" action="search.php" id="searchform">

<div align="center" class="label">

  <p>Search:

    <input name="search_words" type="text" id="search_words" size="30" maxlength="20" />

    <input type="submit" name="GO" id="GO" value="Go" />

  </p>

  <p>

  <input type = "radio" name = "namesearch" id = "namesearch"

value = "AM" <?php if($name == 'namesearch') {echo "checked";}?> >

name search</input>

  <input name = "loginidsearch" type = "radio" id = "loginidsearch" value = "loginidsearch" <?php if($login_id == 'loginidsearch') {echo 'checked';}?>>loginid search<br />

  <input type = "radio" id = "emailsearch" name = "emailsearch" value = "emailsearch" <?php if($email == 'emailsearch') {echo 'checked';}?>>

    email search </input>

  </div>

</form>

    </td>

  </tr>

</table>

 

</p>

 

<?php

if ($search_words != "" && $resultCheck != "")

{

 

 

echo "<table width='650' border='1' align='center' cellspacing='1'>

 

  <tr><tr>

    <td class='passwordsummary_label'>No</td>

    <td class='passwordsummary_label'>Name</td>

    <td class='passwordsummary_label'>Login ID</td>

    <td class='passwordsummary_label'>Password</td>

    <td class='passwordsummary_label'>Email</td>

  </tr>";

 

$i = 1;

while ($row = mysql_fetch_row($result)) //use loop to get the results

{

$name = $row['0'];

$login_id = $row['1'];

$password = $row['2'];

$email = $row['3'];

?>

<td class="passwordsummary_info"><?php echo $i;?></td>

<td class="passwordsummary_info"><?php echo $name;?></td>

<td class="passwordsummary_info"><?php echo $login_id;?></td>

<td class="passwordsummary_info"><?php echo $password;?></td>

<td class="passwordsummary_info"><?php echo $email;?></td>

</tr>

<?php $i++;

}

echo "</table>";

}

else

{

echo '<p class="results">No search results</p>';

}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.