xyn Posted July 14, 2006 Share Posted July 14, 2006 right, I know using queries like:SELECT x,y FROM tbl WHERE field='Value'but I was wondering if this is correct:[code=php:0]include "db.php"; $zql = mysql_query("SELECT mem_mail FROM accounts WHERE id='$act'"); while( $data = mysql_fetch_row($zql)) { $emaillz = $data['mem_mail']; }[/code] Link to comment https://forums.phpfreaks.com/topic/14574-sql-advice/ Share on other sites More sharing options...
brown2005 Posted July 14, 2006 Share Posted July 14, 2006 yeap Link to comment https://forums.phpfreaks.com/topic/14574-sql-advice/#findComment-57819 Share on other sites More sharing options...
shocker-z Posted July 14, 2006 Share Posted July 14, 2006 I'f you're trying to create an array then NO because $emaillz will only contain the last record selected from the table, you would need this[code]include "db.php";$zql = mysql_query("SELECT mem_mail FROM accounts WHERE id='$act'");while( $data = mysql_fetch_array($zql)){ $emaillz[] = $data['mem_mail'];}[/code]Then to echo out all the record further down the page you would need to use somthing like this..[code]foreach ($emaillz as $email) {echo('Email Address: '.$email);}[/code]If there is only 1 record to be returned then might as well just use[code]$zql = mysql_query("SELECT mem_mail FROM accounts WHERE id='$act'");$data = mysql_fetch_array($zql);$emaillz = $data['mem_mail'];As you don't need to loop thru the data as only 1 record will ever be returned.[/code]RegardsLiam Link to comment https://forums.phpfreaks.com/topic/14574-sql-advice/#findComment-57857 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.