EdoDodo Posted June 27, 2007 Share Posted June 27, 2007 Hi. If you have a MySQL table and you only know two of the values for one row (say "Username" and "Password") how can you make a PHP script to tell you the third value on that row (like ID). Thanks in advance, Edo Link to comment https://forums.phpfreaks.com/topic/57423-mysql-searching/ Share on other sites More sharing options...
EdoDodo Posted June 27, 2007 Author Share Posted June 27, 2007 Oh yes, I am using MySQL 4.1 Link to comment https://forums.phpfreaks.com/topic/57423-mysql-searching/#findComment-284096 Share on other sites More sharing options...
per1os Posted June 27, 2007 Share Posted June 27, 2007 Use www.php.net/mysql_fetch_assoc IE: <?php // db connection above $sql = "SELECT * FROM table_name LIMIT 1"; $row = mysql_fetch_array(mysql_query($sql)); foreach ($row as $colname => $val) { $columns .= $colname . "<br />"; } ?> That would work. There is also a nice function http://us2.php.net/manual/en/function.mysql-list-fields.php that should list the fields. Link to comment https://forums.phpfreaks.com/topic/57423-mysql-searching/#findComment-284100 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.