Jump to content

php/mysql problem, fetching curtain info?


ash992

Recommended Posts

Hey guys, to start off as the title says this is a php and MySQL problem so apologies if I've posted this in the wrong place, I'm trying to figure out how I would get MySQL values from a database, but only get ones that have curtain things in common.. confusing description, let me explain,

 

I've got 2 columns in my MySQL database, I have the "UID" Column and the "Type" Column, The UID column just contains a number that is used for each account, it's auto incremented to add one onto the last UID every time a new account is made, so the first account has a UID of 1, second account 2, so on, and the Type column contains two types, "AD" and "WM", Now what I need to do is somehow find a way of echoing all of the UID's that belong to accounts with the type AD, anyone got any idea on how I would do that? Thank-you very much in advance guys, much appreciate it!

Link to comment
https://forums.phpfreaks.com/topic/266188-phpmysql-problem-fetching-curtain-info/
Share on other sites

like this

mysql_connect('servername', 'username', 'password');  // connect to the database server
mysql_select_db('databasename');                      // select your database schema

$sql = "SELECT uid FROM tablename WHERE type = 'AD'"; // define your query
$res = mysql_query($sql);                             // execute the query

if (!$res) {
    die ("$sql<br />".mysql_error());                  // just in case it fails
}

while ($row = mysql_fetch_assoc($res)) {               // loop through the results
    echo $row['uid'] . '<br />';                       //    echo the uid
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.