toksiks Posted May 24, 2011 Report Share Posted May 24, 2011 Teiksim, ka manu datubāzi sauc "table1", iekš tās ir tās tabulas img]http://www.bildites.lv/images/pooekrnocg5gz27jftv8.png[/img], teiksim mēs atveram tabulu "users", tur iekšā ir tās rindas, "username", "password", "id" utt... Ar kādu funkciju var nolasīt lūk šo informāciju un tālāk ar echo izprintēt? Quote Link to comment Share on other sites More sharing options...
Kemito Posted May 24, 2011 Report Share Posted May 24, 2011 1: http://lv.php.net/manual/en/function.mysql-connect.php'>http://lv.php.net/manual/en/function.mysql-connect.php 2: http://lv.php.net/manual/en/function.mysql-query.php'>http://lv.php.net/manual/en/function.mysql-query.php 3.1: http://lv.php.net/manual/en/function.mysql-fetch-object.php'>http://lv.php.net/manual/en/function.mysql-fetch-object.php 3.2: http://lv.php.net/manual/en/function.maxdb-fetch-array.php'>http://lv.php.net/manual/en/function.maxdb-fetch-array.php 4: http://lv.php.net/manual/en/function.maxdb-fetch-array.php'>http://lv.php.net/manual/en/function.maxdb-fetch-array.php 4.2: http://lv.php.net/manual/en/control-structures.foreach.php'>http://lv.php.net/manual/en/control-structures.foreach.php 5: http://lv.php.net/manual/en/function.echo.php'>http://lv.php.net/manual/en/function.echo.php DIMMM...? this one? -> http://lv.php.net Quote Link to comment Share on other sites More sharing options...
daGrevis Posted May 24, 2011 Report Share Posted May 24, 2011 $sql = " SELECT `id`, `username`, `password` FROM `users` "; $query = mysql_query( $sql ) || exit( mysql_error() ); while ( $row = mysql_fetch_assoc( $query ) ) { echo $row['id'] . ' ' . $row['username'] . ' ' . $row['password']; } Nu šitā tiks nolasītas visas vērtības katram ierakstam 'users' tabulā. Tikai pirms tam ir jāsavienojas ar serveri un jāizvēlas pareizā datubāze. mysql_connect( 'localhost', 'daGrevis', '123456' ); mysql_select_db( 'datubāze' ); Un tad, ja vajag ko citu... teiksim tikai viena ieraksta paroli, piemēram... $sql = " SELECT `password` FROM `users` WHERE `username` = 'daGrevis' "; $query = mysql_query( $sql ) || exit( mysql_error() ); echo mysql_result( $query, 0 ); Googles tante ir Tavs draugs! Un jā, vispār mūsdienās vajadzētu izmantot MySQLi vai PDO, bet šitais ir tikai piemērs. Quote Link to comment Share on other sites More sharing options...
Snapins Posted May 24, 2011 Report Share Posted May 24, 2011 daGrevis, vot uzrakstija diezgan lieliski.. (: Un ta arī ir pareizi. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted May 24, 2011 Report Share Posted May 24, 2011 Par to ielieciet Manā profilā piecas zvaigznītes! Ha, ha. Quote Link to comment Share on other sites More sharing options...
Rincewind Posted May 24, 2011 Report Share Posted May 24, 2011 O, strādā! Kā datus atpakaļ datubāzē ielikt kad viņi vairs nav vajadzīgi? Quote Link to comment Share on other sites More sharing options...
Kemito Posted May 24, 2011 Report Share Posted May 24, 2011 Nu jā jau jau iebāž ar pirkstu mutē tad jau ir labi ! :D Nu viņi tur glabājas, viņi atpakaļ nav jāliek. JA gribi mainīt tos, tas ir kas cits. Quote Link to comment Share on other sites More sharing options...
codez Posted May 24, 2011 Report Share Posted May 24, 2011 O, strādā! Kā datus atpakaļ datubāzē ielikt kad viņi vairs nav vajadzīgi? Kad tu izlasi grāmatu, tā arī no jauna jādrukā? Quote Link to comment Share on other sites More sharing options...
toksiks Posted May 29, 2011 Author Report Share Posted May 29, 2011 Tātad šādi izskatās man tas viss - http://pastebin.com/F2ZbdbbT , mēģināju pēc Jūsu piemēriem echo'ot, bet nav sanācis, būtu pateicīgs, ja kāds ielietu ar karoti mutē kā būtu pareizi izecho'ot no kāda "row" datus, paldies. Quote Link to comment Share on other sites More sharing options...
daGrevis Posted May 29, 2011 Report Share Posted May 29, 2011 1) Ieslēdz error_reporting(), 2) Tev septītajā rindiņā ir sintakses kļūda; 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.