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
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
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.