ash992 Posted July 24, 2012 Share Posted July 24, 2012 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 More sharing options...
Barand Posted July 24, 2012 Share Posted July 24, 2012 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 https://forums.phpfreaks.com/topic/266188-phpmysql-problem-fetching-curtain-info/#findComment-1364086 Share on other sites More sharing options...
ash992 Posted July 24, 2012 Author Share Posted July 24, 2012 Thank-you so much! That's awesome. Thanks again, was a lot of help. Link to comment https://forums.phpfreaks.com/topic/266188-phpmysql-problem-fetching-curtain-info/#findComment-1364088 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.