There are tables. How can I do that if there are no user data in the field, then it was hidden, not shown?

<table> <tr> <td class="grayinfotypetable">City:</td> <td><a>Minsk</a></td> </tr> <tr> <td>Phone number:</td> <td><span class="grayitem">no no no</span></td> </tr> <tr> <td>Home number:</td> <td><span class="grayitem">no no no</span></td> </tr> <tr> <td>skype:</td> <td><span class="grayitem"><a href="skype:predator_x702?call">predator_x702</a></span></td> </tr> <tr> <td>Web-site:</td> <td><span class="grayitem"><a> http://www.google.com </a></span></td> </tr> </table> 


    1 answer 1

    Pull records from a database with a certain condition. For example, select all entries where the username is not equal to "void".

     $res = mysql_query("SELECT * FROM users WHERE user_name != ''"); 
    • Thank you, but if you mean a user profile, how is it in contact with such a volume of information? ? - OverLoader
    • one
      The methods depend on the structure of the database. If you store all the information about the user in one table, which is not good, you will have to check each variable for emptiness. Therefore, I think that there should be two tables. For example, users and user_info . In user_info , in each row, store the user id from the first table, the second field - the name of the information (or city, or phone, etc.), and in the third field - the corresponding value: Minsk, 02 etc. - Deonis
    • PS I can assume that you will have difficulty with how to add / update fields in the user_info table. I hope that you are friends with MySQL queries, then look towards the " INSERT ... ON DUPLICATE KEY UPDATE ... " construction. - Deonis
    • one
      @Deonis in normal sql in user_info with one batch, first delete all data on the user, then write new ones, then you don’t need a duplicate key udpate, and you don’t need additional gestures about cleaning fields. - Yura Ivanov
    • @Yura Ivanov, in general, yes. It is possible in this way. ---------- You can rephrase the answer @AlexWindHope> to argue with a 35-year-old programmer is a rotten occupation ... ... when I myself already have 37))) - Deonis