ming_andrada Posted July 24, 2008 Share Posted July 24, 2008 hi geek guys, i'm still learning php... i'm not yet using classes... that's why i'm stuck with this script but the problem is i always fall on the "Search found no records." pls do help me, if anyone can edit it... that's not a problem it could be a great help... take a look at my script it's kinda long...please have mercy... thank you very very much.... <? //Client Search Script if ($_SESSION['username'] == null){ header ('Location: http://'.$_SERVER['HTTP_HOST'].'/index.php'); exit(); }else{ include('dbh.php'); $headertitle = 'Client Search'; print'<br /><br /><span class="welcome"><b>Client Search</b></span>'; $clientlname = 'clientlname'; if (isset($_POST['Search'])) { if (empty($_POST['clientlname'])) { $clientlname = '' ; }else{ $clientlname = "clientlname = '{$_POST['clientlname']}' "; } if (empty($_POST['clientfname'])) { $clientfname = '' ; }else{ $clientfname = "clientfname = '{$_POST['clientfname']}' "; } $equery = "SELECT * FROM clientdata WHERE clientid = '$clientid' AND clientlname = '$clientlname' OR clientlname = '$clientlname' " ; $result = mysql_query($query); $num_records = @mysql_num_rows ($result); if ($num_records <= 0) { print "<br /><div align=\"left\">Search found no records.</div><br />"; }else{ print '<table width="650" border="0" cellpadding="2" cellspacing="1">'; print '<TR align="center" bgcolor="#66CC33"> <td width="10%">Edit/Delete</td> <td width="20%">Client ID</td> <td width="10%">Client Name.</td>'; for($i = 0; $i < $num_records; $i++) { $row = mysql_fetch_array($result); if($i % 2) { print '<TR align="center" bgcolor="#FFCCCC">'; } else { print '<TR align="center" bgcolor="#FF66FF">'; } print'<td><a href="clientsummary.php?clientid='.$row['clientid'].'">Edit</a>/<a href="cliserdel.php?clientid='.$row['clientid'].'">Delete</a></td>'; $clientid = $row['clientid']; print' <td> '.$row['clientid'].'</td>'; print'<td> '.$edata['clientlname'].', '.$edata['clientfname'].'</td>'; print '</TR>'; } print '</table>'; } }else{ print'<table width="710" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" valign="top"><form id="form1" name="form1" method="post" action="clientsearch.php"> <table width="550" border="0" align="left" cellpadding="0" cellspacing="0"> <tr> <td width="138" rowspan="2" align="left" valign="top"><br /></td> <td width="148" rowspan="2" align="left" valign="top"></td> <td colspan="2" align="left" valign="top"></td> </tr> <tr> <td align="left" valign="top"></td> <td align="left" valign="top"></td> </tr> <tr> <td colspan="2" align="left" valign="top">Complete search field below.</td> <td align="left" valign="top"> </td> <td align="left" valign="top"> </td> </tr> <tr> <td width="138" height="27" align="left" valign="top">Client Last Name: </td> <td width="148" align="left" valign="top"><select name="clientlname" class="form" id="clientlname"><option value="">Any</option>\n'; $clientlname = mysql_query('SELECT * FROM clientdata order by clientlname ASC'); while($clientlrow = @mysql_fetch_array($clientlname)) { print '<option value="'.$clientlrow['clientid'].'">'.$clientlrow['clientlname'].'</option>\n'; } print'</select></td> </tr> <tr> <td width="138" height="27" align="left" valign="top">Client Last Name: </td> <td width="148" align="left" valign="top"><select name="clientfname" class="form" id="clientfname"><option value="">Any</option>\n'; $clientfname = mysql_query('SELECT * FROM clientdata order by clientfname ASC'); while($clientfrow = @mysql_fetch_array($clientfname)) { print '<option value="'.$clientfrow['clientid'].'">'.$clientfrow['clientfname'].'</option>\n'; } print'</select></td> </tr> <tr> <td align="left" valign="top"> </td> <td colspan="3" align="left" valign="top"> </td> </tr> <tr> <td align="left" valign="top"> </td> <td align="left" valign="top"> </td> <td align="left" valign="top"> </td> <td align="left" valign="top"><div align="right"> <input name="Search" type="submit" class="form" id="Search" value="Search" /> </div></td> </tr> <tr> <td align="left" valign="top"> </td> <td align="left" valign="top"> </td> <td align="left" valign="top"> </td> <td align="left" valign="top"> </td> </tr> <tr> <td align="left" valign="top"> </td> <td colspan="3" align="left" valign="top"><div align="right"></div></td> </tr> </table> </form> </td> </tr> </table>'; } } ?> Link to comment https://forums.phpfreaks.com/topic/116358-help-search-script-error/ Share on other sites More sharing options...
MasterACE14 Posted July 24, 2008 Share Posted July 24, 2008 first of all, you dont need that else right at the start. if the session bar username is null, it will exit the script..... secondly, im still reading through it lol -Edit, done reading. Theres some problems with the variable setting near the start. change this: if (empty($_POST['clientlname'])) { $clientlname = '' ; }else{ $clientlname = "clientlname = '{$_POST['clientlname']}' "; } if (empty($_POST['clientfname'])) { $clientfname = '' ; }else{ $clientfname = "clientfname = '{$_POST['clientfname']}' "; } $equery = "SELECT * FROM clientdata WHERE clientid = '$clientid' AND clientlname = '$clientlname' OR clientlname = '$clientlname' " ; to this: if (empty($_POST['clientlname'])) { $clientlname = '' ; }else{ $clientlname = "clientlname = '{$_POST['clientlname']}' "; } if (empty($_POST['clientfname'])) { $clientfname = '' ; }else{ $clientfname = "clientfname = '{$_POST['clientfname']}' "; } $equery = "SELECT * FROM clientdata WHERE clientid = '$clientid' AND " . $clientlname . " OR " . $clientlname . " " ; and alter $result to this... $result = mysql_query($query) or die("lol fail noob \n".mysql_error()); Regards ACE Link to comment https://forums.phpfreaks.com/topic/116358-help-search-script-error/#findComment-598293 Share on other sites More sharing options...
ming_andrada Posted July 24, 2008 Author Share Posted July 24, 2008 hi ACE, thanks geek... dude, i removed the "else" on the start but nothing happened, the only thing that appeared on my screen is my template... huhhuhu... have mercy again... thanks a lot! Link to comment https://forums.phpfreaks.com/topic/116358-help-search-script-error/#findComment-598334 Share on other sites More sharing options...
MasterACE14 Posted July 24, 2008 Share Posted July 24, 2008 hmm, I really don't know whats wrong with it lol. Maybe I'm just too tired :-\ Link to comment https://forums.phpfreaks.com/topic/116358-help-search-script-error/#findComment-598337 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.