retrieving data for particular logging user............

In this after the query select * from users … m gettng error by writing where …what should i use so as to print the particular user information …

<?php $con=mysql_connect("localhost","root",""); mysql_select_db("ttlogin", $con); $result=mysql_query("SELECT * FROM users"); $row = mysql_fetch_array($result) ?>

help regarding the same…

In this after the query select * from users .............. m gettng error by writing where .....what should i use so as to print the particular user information ...................

It is not clear exactly what you are asking here. Are you asking how to print what went wrong with the MySQL query?

I also understand you want to see the results back from your query as well.

I’ve made annotations to your PHP code so I and others can try to dissect what’s going on, and you can understand to a degree what each piece of code does.
[php]

<?php //This is your connection code. I would recommend changing the default MySQL login information for security purposes, a.k.a. creating a password for root, or creating a new account that has limited privileges. This should be relatively easy to do in MySQL Workbench. Or whatever you prefer to use. $con=mysql_connect("localhost","root",""); //You are selecting the ttlogin database using the connection information above mysql_select_db("ttlogin", $con); //You've selected everything from the user table. Grave accent punctuation marks ( ` ` ) are recommended for specifying tables properly. $result=mysql_query("SELECT * FROM `users`"); //If no result if(!$result) { $message = 'Query Error: ' . mysql_error(); $message .= 'Query Str: "SELECT * FROM `users`"); die ($message) //Now you've put the data into an array of variables here. The next thing to do would be to tell PHP which variables you want out of the table. Something like: //While There is data being fetched by each query while ( $row = mysql_fetch_array($result) ) { //Since I don't know what table setup you have, this would be a general layout. //Assign each row value to a variable $data1 = $row['data_value1']; $data2 = $row['data_value2']; $data3 = $row['data_value3']; //Print the data to the screen printf ("[ 1: $data1, 2: $data2, 3: $data3 ]
"); } ?>

[/php]

I will not consider myself an expert nor even an intermediate. But this would be the general plan that you would want to go with if I understand what you want correctly.

You can find the list of MySQL API functions here:

http://us.php.net/manual/en/book.mysql.php

i did this , but the main problem is that i want to retrieve particular user detail when user gets login into that
like( select * from tablename where username=’’) i have to complete this query in which i m facing problem , i m unable to write wht shld b der aftr where clause so dat i can select the full information about that particular username who has login
with respect to this its givng only first registered member information in everyone login my full code is given here

<?php $con=mysql_connect("localhost","root",""); mysql_select_db("ttlogin", $con); $result=mysql_query("SELECT * FROM users"); $row = mysql_fetch_array($result) ?>
    </br>
       USER ID :
          <?php
     
            echo $row['id'];
      
           ?>
       FULL NAME :
         <?php  
            
           echo $row['fullname']; 
        
          ?></br>
       USER NAME :
          <?php
     
            echo $row['username'];
      
           ?></br>
   </br>
       EMAIL ADDRESS :
          <?php
     
            echo $row['emailaddress'];
      
           ?>
         </br>
   </br>
       PHONE NUMBER :
          <?php
     
            echo $row['phonenumber'];
      
           ?>
	
    </br>
   </br>
       GENDER :
          <?php
     
            echo $row['gender'];
      
           ?>
    </br>
   </br>
       REGISTERED DATE :
          <?php
     
            echo $row['date'];
      
           ?>
...i want to retrieve particular user detail when user gets login into that like( select * from tablename where username='') i have to complete this query in which i m facing problem , i m unable to write wht shld b der aftr where clause so dat i can select the full information about that particular username who has login

I believe that should be written as:

[php]
mysql_query(‘SELECT * FROM users WHERE username=’$username’)
[/php]

Where $username is the user that you are interested in. It should return one row of data. Just remember that the array created from mysql_fetch_array, the keys must match exactly the table column names in the database.

Sponsor our Newsletter | Privacy Policy | Terms of Service