Snaip3Rs Posted February 21, 2010 Report Share Posted February 21, 2010 Kā var izvilkt datus no db lai piemēram ieeju profilā un tur rāda cilvēka datus pēc ID <?php $con = mysql_connect("localhost","admin","jz"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); $result = mysql_query("SELECT * FROM members"); while($row = mysql_fetch_array($result)) { echo $row['username'] . " " . $row['ptz']; echo "<br />"; } mysql_close($con); ?> Piemēram username izvilkt no db. Kā to var izdarīt tas ir tik vienkārš jautājums bet man nesanāk! :( Quote Link to comment Share on other sites More sharing options...
sandis_m Posted February 21, 2010 Report Share Posted February 21, 2010 <?php $result = mysql_query("SELECT * FROM members ORDER BY id"); Quote Link to comment Share on other sites More sharing options...
chizijs Posted February 21, 2010 Report Share Posted February 21, 2010 (edited) Dilstošā secībā $result = mysql_query("SELECT * FROM members ORDER BY id DESC"); Augošā secībā $result = mysql_query("SELECT * FROM members ORDER BY id ASC"); Edited February 21, 2010 by chizijs Quote Link to comment Share on other sites More sharing options...
Kemito Posted February 21, 2010 Report Share Posted February 21, 2010 (edited) SPIED NĀVĪGI STINGRI Pavisam jauki :) Edited February 21, 2010 by Kemito Quote Link to comment Share on other sites More sharing options...
nemakuphp Posted February 21, 2010 Report Share Posted February 21, 2010 Tev kaut kādā veidā ir jāiegūst profila ID, kuru vēlies apskatīt. <?php $con = mysql_connect("localhost","admin","jz"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); $id = intval($_GET['id']); $result = mysql_query("SELECT * FROM members WHERE id = '".$id."' LIMIT 1"); $row = mysql_fetch_array($result); print_r($row); mysql_close($con); ?> Tālāk pats skaties ko vari attēlot un to arī attēlo Quote Link to comment Share on other sites More sharing options...
sandis_m Posted February 21, 2010 Report Share Posted February 21, 2010 Prikols tāds, ka nemakuphp saprata jautājumu... Fak ...es pārskatījos un kko nepatēmu. Quote Link to comment Share on other sites More sharing options...
Snaip3Rs Posted February 21, 2010 Author Report Share Posted February 21, 2010 Paldies sanāca, bet kā man uztaisīt lai attēlo tikai username email ptz Lūkur kods! <?php if($profile_details != NULL) { // use $profile_details to output the users details that // we fetched from out database earlier, I'm just going // to output all the user info to prove it works foreach($profile_details as $k => $v) { echo $k . " = " . $v . "<br />"; } } else { // display our error message echo $error_feedback; } ?> $k = $v izvada pat paoli un parāda visiem pārējiem. Kā to novērst? Quote Link to comment Share on other sites More sharing options...
nemakuphp Posted February 21, 2010 Report Share Posted February 21, 2010 <?php $con = mysql_connect("localhost","admin","jz"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); $id = intval($_GET['id']); $result = mysql_query("SELECT * FROM members WHERE id = '".$id."' LIMIT 1"); $row = mysql_fetch_array($result); echo $row['username'].'<br />'.$row['email'].'<br />'.$row['ptz']; mysql_close($con); ?> Quote Link to comment Share on other sites More sharing options...
Snaip3Rs Posted February 22, 2010 Author Report Share Posted February 22, 2010 Šajā lapā man izdevās izvadīt lietotājvārdu un visu pārējo, bet sākumlapā nesanāk! Te būs kods: <? session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); } ?> <INPUT TYPE="BUTTON" VALUE="Iziet" ONCLICK="window.location.href='logout.php'"> <INPUT TYPE="BUTTON" VALUE="Lietotaji" ONCLICK="window.location.href='members.php'"> <?php $con = mysql_connect("localhost","admin","jz"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); $id = intval($_GET['id']); $result = mysql_query("SELECT * FROM members WHERE id = '".$id."' LIMIT 1"); $row = mysql_fetch_array($result); mysql_close($con); ?> Hello: <?php echo $row['username']; ?> Quote Link to comment Share on other sites More sharing options...
briedis Posted February 22, 2010 Report Share Posted February 22, 2010 ir kļūdas ziņojumi? Debuggoji? Pārbaudīji dažādu mainīgo vērtības? Quote Link to comment Share on other sites More sharing options...
2easy Posted February 22, 2010 Report Share Posted February 22, 2010 briedi, ko tu uzdod tik daudz muļķīgus jautājumus? protams, ka nē! :D:D:D Quote Link to comment Share on other sites More sharing options...
nemakuphp Posted February 22, 2010 Report Share Posted February 22, 2010 Tev kaut kā ir jāiegūst lietotāja ID, piemēram, no sesijas vai cepuma Quote Link to comment Share on other sites More sharing options...
Snaip3Rs Posted February 22, 2010 Author Report Share Posted February 22, 2010 Briedi tā ir tā lieta ka error nemet ārā parasts text uzrādās bet no db nevelk ārā username! Un ja es taisu ar cokie tad man nav jāpārtaisa register un login lapa? Quote Link to comment Share on other sites More sharing options...
briedis Posted February 22, 2010 Report Share Posted February 22, 2010 (edited) Briedi tā ir tā lieta ka error nemet ārā parasts text uzrādās bet no db nevelk ārā username! Un ja es taisu ar cokie tad man nav jāpārtaisa register un login lapa? nu a tu pirms kvērija izvadī, vai Id kaut ko satur, un paskaties vai datubāzē toč ir ar tādu id. VAJAG DEBUGGOT!!!! AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAa fak, ja kas te saskartos ar problemu vispirms visam kodam izbrauktu cauri, dažādās vietās pārbaudītu mainīgo vērtības, ieslēgtu kļūdu paziņojumus, tad te būtu uz pusi mazāk muļķīgu jautājumu... Dziļa ieelpa 1..2..3..4.. briedis ir nomierinājies. Edited February 22, 2010 by briedis Quote Link to comment Share on other sites More sharing options...
waplet Posted February 22, 2010 Report Share Posted February 22, 2010 Varbūt izskaidrojiet viņām vārda - debuggot - nozīmi ? D 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.