if (!$con) { die('Could not connect: ' . mysql_error()); }
mysql_select_db("IpPhoneDir", $con);
// Send a query to the server if ($result = mysql_query($con, "call GetBranchBeg($srch)")) {
$um_rows = mysql_num_rows($result); if($num_rows <= 0) { echo "no match found"; } print "<table border = 1>n";
//get row data as an associative array While ($row = mysql_fetch_assoc($result)) { print "<tr>n"; //look at each field foreach ($row as $col=>$val){ print "<td>$val</td>n"; }//end foreach print "</tr>nn"; }//end while- print "</table>n";
Code: [Select]DROP PROCEDURE `GetBranchBeg`// CREATE DEFINER=`root`@`localhost` PROCEDURE `GetBranchBeg`(IN starts_with CHAR(15)) BEGIN DECLARE tmp CHAR(15); SET tmp = CONCAT(starts_with, '%'); SELECT IpPhoneNo, location FROM IpPhoneList WHERE location LIKE tmp OR location =starts_with; END