•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 397,790 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,409 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 698 | Replies: 1
![]() |
•
•
Join Date: Jan 2007
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Me and a buddy wrote some php code, and it searches the db for the string, returning results... The problem is, it only returns results for certain strings I search, for example, if I search a last name "Rodriguez", it works... if I search "Ro", it works. But if I search "Roq", nothing comes back... and I indeed have entries in the DB that would match that... When I search "Ro", they all appear, but if I try to specify further in the search, no results. This happens for most cases infact, with "Rodriguez" being one of the few cases the search is successful. I have no clue why this is happening.
This is snippet 1:
This is snippet 2:
This is snippet 1:
php Syntax (Toggle Plain Text)
if (($action == "view")|($action == "delete")|($action == "deleteyes")|($action == "deletefile")|($action == "deletefileyes")) { if ($action == "view") { $clientid = $_GET['clientid']; $query = "SELECT * FROM insurance WHERE clientid='$clientid'"; $result = mysql_query($query) or die (mysql_error()); $num_rows = mysql_num_rows($result); if ($num_rows == "") { echo "Could Not Select CLIENTID"; return 0; } while($rows = mysql_fetch_assoc('$result')) { $name = $rows["name"]; $policyno = $rows["policyno"]; $type = $rows["type"]; $clientid = $rows["clientid"]; echo "<br>"; echo "<dd><dd><dd><dd><dd><dd>NAME: $name<br>"; echo "<dd><dd><dd><dd><dd><dd>POLICY NUMBER: $policyno<br>"; echo "<dd><dd><dd><dd><dd><dd>POLICY TYPE: $type<br>"; echo "<dd><dd><dd><dd><dd><dd>CLIENT ID: $clientid<br>"; } echo "<center><br>"; // open this directory $blank = ""; $dir = "$clients".$clientid."".$blank; $myDirectory = opendir($dir); // get each entry while($entryName = readdir($myDirectory)) { $dirArray[] = $entryName; } // close directory closedir($myDirectory); //count elements in array $indexCount = count($dirArray); // sort 'em sort($dirArray); // print 'em print("<TABLE border=1 cellpadding=5 cellspacing=0 class=whitelinks width=60%>\n"); print("<TR><TH align=left>Filename</TH><TH>Action</th></TR>\n"); // loop through the array of files and print them all for($index=0; $index < $indexCount; $index++) { if (substr("$dirArray[$index]", 0, 1) != "."){ // don't list hidden files print("<TR><TD width=80%><a href=\"Z:/Clients/$clientid/$dirArray[$index]\">$dirArray[$index]</a></td>"); print("<td width=16%><a href='Z:/Clients/$clientid/$dirArray[$index]'>[view]</a> <a href='insurance.php?action=deletefile&clientid=$clientid&file=$dirArray[$index]'>[remove]</a></td>"); print("</TR>\n"); } } print("</TABLE>\n"); echo "<br><center>[scan] [attach]<br><a href='insurance.php?'>[home]</a></center>"; }
This is snippet 2:
php Syntax (Toggle Plain Text)
if (($value1 == "name")|($value1 == "policyno")|($value1 == "type")) { # do some sense checking... if ($value2 == "") { $substring1 = ""; } else { $substring1 = "AND $value2 = '$field2'"; } if ($value3 == "") { $substring2 = ""; } else { $substring2 = "AND $value3 = '$field3'"; } if ($value4 == "") { $substring3 = ""; } else { $substring3 = "AND $value4 = '$field4'"; } # replace all spaces with MySQL wildcards... $field1 = str_replace(" ","%",$field1); $field2 = str_replace(" ","%",$field2); $field3 = str_replace(" ","%",$field3); # set the query string... $query = "SELECT * FROM insurance WHERE $value1 LIKE ('%$field1%') $substring1 $substring2 $substring3"; # execute the query... $result = mysql_query($query); # split the results and set further variables... $num_rows = mysql_num_rows($result); $num_fields = mysql_num_fields($result); if ($num_rows == 0) { echo "No Results<br>"; return 0; } echo "<center>"; echo "<table border=1 width=65%>"; echo " <tr>"; echo " <th>NAME</th>"; echo " <th>CLIENT ID</th>"; echo " </tr>"; while($row = mysql_fetch_row($result)) { for ($i=0;$i<=$num_rows;$i++) { $id = "$row[$i]"; $query = "SELECT * FROM insurance WHERE id=$id"; $results = mysql_query($query); while($rows = mysql_fetch_assoc($result)) { $name = $rows["name"]; $policyno = $rows["policyno"]; $type = $rows["type"]; $clientid = $rows["clientid"]; echo " <tr>"; echo " <td width=44%>"; echo " <a href='insurance.php?action=view&clientid=$clientid'>$name</a>"; echo " </td>"; echo " <td width=44%>"; echo " <a href='insurance.php?action=view&clientid=$clientid'>$clientid</a>"; echo " </td>"; echo " <td width=6%>"; echo " <a href='insurance.php?action=view&clientid=$clientid'>[view]</a>"; echo " </td>"; echo " <td width=6%>"; echo " <a href='insurance.php?action=delete&clientid=$clientid'>[remove]</a>"; echo " </td>"; echo " </tr>"; } } }
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
Similar Threads
- Adaware won't remove VX2 nasty (Viruses, Spyware and other Nasties)
- need help removing callinghomebiz (Viruses, Spyware and other Nasties)
- Help me get rid of hot offers (Viruses, Spyware and other Nasties)
- HijackThis error? (Viruses, Spyware and other Nasties)
- Think I have VX2 and others...Logs posted (Viruses, Spyware and other Nasties)
- VX2 burning me, need help plz (Viruses, Spyware and other Nasties)
- How do you integrate a database w/web design? best solution for online catalogue? (Database Design)
Other Threads in the PHP Forum
- Previous Thread: Zune Site help
- Next Thread: Possible to let the user know the image is too large


Linear Mode