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] Quote 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 Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/14574-sql-advice/#findComment-57857 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.