Chapman Posted February 19, 2010 Report Share Posted February 19, 2010 Vārds un uzvārds man glabājas DB atsevišķos laukos, bet, pie ievades man sanāk, ka tie Input lauka vērtība ir "Vārds Uzvārds", vai ar mssql_query ir iespejas kaut kādā viedā atlasīt visus ierakstus, kuri ir vienādi ar Input lauka vērtību? piem. kaut kā tā: mssql_query ( "SELECT * FROM S_Users WHERE Name + Surname=$vards_uzvards"; ); Input laukā abi tiek ierakstītī ar atstarpi pa vidu! Quote Link to comment Share on other sites More sharing options...
eT` Posted February 19, 2010 Report Share Posted February 19, 2010 (edited) a vai tad nevar: $v = $POST["vards"]; $e = explode(' ',$v); un tad būs masīvs ar 2 elemetiem ( vārdu un uzvārdu ) un tad SELECT * FROM lietotaaji WHERE Name='$e[0]' AND Surname='$e[1]' nu kautkā tā. ja šitas darbojas tad esmu pamodies :D Edited February 19, 2010 by eT` Quote Link to comment Share on other sites More sharing options...
briedis Posted February 19, 2010 Report Share Posted February 19, 2010 (edited) Vispār izskatās, ka nav tāda īsti vienkārša veida, kā to izdarīt ar tsql.. Bet vispār kāpēc tev to nedarīt ar php?? list($vards, $uzvards) = explode(" ", $vards_un_uzvards); Edited February 19, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
marcis Posted February 19, 2010 Report Share Posted February 19, 2010 Vismaz ar MySQL nav problēmu :) SELECT * FROM `users` WHERE CONCAT(name, ' ', sname)='vards uzvards' Quote Link to comment Share on other sites More sharing options...
Chapman Posted February 19, 2010 Author Report Share Posted February 19, 2010 (edited) izskatās, ka mssql tādas funkcijas nav :( Warning: mssql_query() [function.mssql-query]: message: 'CONCAT' is not a recognized built-in function name. (severity 15) in C:\xampp\htdocs\sublapas\admin_users.php on line 66 pašlaik kods izskatās šādi: <table class="In" border="1"> <tr> <td width="250" align="center"> <form name="user_options_form" method="post" action=""> <table border="0" cellpadding="2" cellspacing="0"> <tr> <td width="300" align="center"> Lūdzu izvēlaties lietotāju: </td> </tr> </tr> <td align="center"> <select id="users_list" onchange="users()" size="10"> <?php while ($row = mssql_fetch_assoc($users_query)) { ?> <option> <?php echo $row["F_Name"].' '.$row["S_Name"]?> </option> <?php }?> </select> </td> </tr> <tr> <td align="center"> <input type="text" id="selected_user" size="20"></p> </td> </tr> <tr> <td align="center" valign="center" height="30"> <input type="submit" value="Rediģēt Lietotāju" name="user_options"> </td> </tr> </table> </form> </td> <td> <?php if (isset($_POST['user_options'])) { mssql_connect("$host", "$username", "$password")or die("Never pieslēgties Serverim"); mssql_select_db("SecKeyPrior")or die("Nevar pieslēgties Datu Bāzei"); $selected_user=$_POST['selected_user']; list($adm_F_Name, $adm_L_Name) = explode(" ", $selected_user); $user_select = "SELECT Id FROM S_Users WHERE F_Name='$adm_F_Name' and S_Name='$adm_L_Name'"; $user_select = mssql_query( $user_select ); $user_select = mssql_fetch_row($user_select); $user_select = $user_select[0]; echo $user_select; echo $adm_F_Name; } ?> </td> </tr> </table> nospiežot pogu, tik un tā neko neizdava! Edited February 19, 2010 by Chapman Quote Link to comment Share on other sites More sharing options...
briedis Posted February 19, 2010 Report Share Posted February 19, 2010 (edited) Esi pārliecināts, ka tur tāda vērtība ir? paprovē vārds - "1", uzvārds "2" un tad meklē pēc "1 2" Kļūdu ziņojumi kādi? Edited February 19, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted February 19, 2010 Report Share Posted February 19, 2010 Pameklējot googlē mssql+concat var atrast, ka to dara šādi. SELECT IdFlight, OrganizerLastName + ', ' + OrganizerFirstName + 'Flt:' + FlightNumber AS Concat FROM TableFlights ORDER BY OrganizerLastName, OrganizerFirstName ; Tavā gadījumā SELECT * FROM `users` WHERE name+' '+sname='vards uzvards' Quote Link to comment Share on other sites More sharing options...
2easy Posted February 19, 2010 Report Share Posted February 19, 2010 viņam jau tas pats vien ir tikai bez ' '. ja jau tā varētu, tad jau nebūt nācis prasīt labāk izmantot AND. var jau arī virs tabulas taisīt view, kurā apvieno šos laukus dinamiski zem jauna nosaukuma, tipa Title (ja tā var), un selektēt no šī view, nevis pa tiešo no tabulas. tad varēs WHERE Title = $vards_uzvards, jo title būs pie selektētajiem laukiem. bet nu dēļ šāda sīkuma nebūtu vērts tā ņemties. labāk AND Quote Link to comment Share on other sites More sharing options...
xPtv45z Posted February 19, 2010 Report Share Posted February 19, 2010 ahh, nepamanīju.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.