php - Connecting Search Form to MySQL Database And Display Results -
this question has reply here:
mysql_fetch_array()/mysql_fetch_assoc()/mysql_fetch_row() expects parameter 1 resource or mysqli_result, boolean given 32 answerson members page of website, need have alternative members can info of other members. far have done create search form...
<form id="searchform" name="searchform" action="searchresults.php" method="post"> search membership <input type="text" name="search" id="textfield" placeholder="search members" /> <input type="submit" name="button" id="button" value="search" /> </form>
i've created table in database of members info. need help getting form communicate database table , take inputted search form , display results on results page.
i not familiar , help appreciated. thanks.
update: have next php code on searchresults.php page...
<?php error_reporting(-1); $host=""; $username=""; $password=""; $db_name=""; $tbl_name="moamembersearch"; mysql_connect($host, $username, $password) or die("cannot connect"); mysql_select_db($db_name) or die("cannot select db"); $sql = "select * moamembersearch"; $result = mysql_query($sql); $row = mysql_fetch_array($result); if (false === $result) { echo mysql_error(); } ?> <!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=utf-8" /> <title>member search - moa</title> <link href="css/style.css" rel="stylesheet" type="text/css" /> <link href="css/jquery.ennui.contentslider.css" rel="stylesheet" type="text/css" media="screen,projection" /> <style type="text/css"> #content_wrapper #content table { color: #000; } </style> </head> <body> <div id="menu_wrapper"> <div id="menu"> <ul> <li><a href="index.html">home</a></li> <li><a href="boardofdirectors.html">board</a></li> <li><a href="members.php" class="current">members</a></li> <li><a href="ratingcard.html">rating card</a></li> <li><a href="join.html">join moa</a></li> <li><a href="contact.html">contact us</a></li> </ul> </div> <!-- end of menu --> </div> <!-- end of menu wrapper --> <div id="header_wrapper"> <div id="header"><!-- end of slider --> </div> <!-- header --> </div> <!-- end header wrapper --> <div id="content_wrapper"> <div id="content"> <h1>search results</h1> <table width="930" border="0" style="font-size:12px"> <tr> <th>sports</th> <th>last name</th> <th>first name</th> <th>address</th> <th>city</th> <th>state</th> <th>zip</th> <th>phone 1</th> <th>phone 2</th> <th>email</th> </tr> <tr> <td><?php echo $rows['sports']; ?></td> <td><?php echo $rows['lastname']; ?></td> <td><?php echo $rows['firstname']; ?></td> <td><?php echo $rows['address']; ?></td> <td><?php echo $rows['city']; ?></td> <td><?php echo $rows['state']; ?></td> <td><?php echo $rows['zip']; ?></td> <td><?php echo $rows['phone1']; ?></td> <td><?php echo $rows['phone2']; ?></td> <td><?php echo $rows['email']; ?></td> </tr> </table>
currently getting error search results should appearing
first, utilize mysqli. save headaches , improve security. then, looking @ form recieve page.
<?php $con = mysqli_connect(address,user,pass,database); if(isset($_post['search'])) { $result = mysqli_query($con,"select * members name='".mysqli_real_escape_string($con,$_post['search'])."'"); if(mysqli_num_rows($result)!=0) { $row = mysqli_fetch_array($result); //$row associated array of fellow member data, echo want here } else { //no results } } ?>
php mysql database forms search
No comments:
Post a Comment