php - Set a variable equal to result of Mysql query -


i have 2 mysql tables - membership , renewals2017. want set variable called $email value of following query, not sure doing correctly. tables inner joined member_id in membership table , m_id in renewals2017 table. value of email in membership table. reason want set variable $email because using value send email. here query:

set $email = ("select membership.e_mail_address membership inner join renewals2017 on renewals2017.m_id = membership.member_id";); 

if there better way this, or not correct, please let me know. thank you.

there (currently) no keyword set in php, declare variable assigning value it.

use mysqli_connect() connect database, mysqli_query() perform query, , fetch_array() iterate on each returned record - see example below:

//update parameters per credentials below $connection = mysqli_connect("databaseserver", "username", "password", "databasename"); $query = $connection->query("select membership.e_mail_address membership inner join renewals2017 on renewals2017.m_id = membership.member_id"); while($result = $query->fetch_array(msqli_assoc)) {     $email = $result['e_mail_address']; //one each resulting record } 

you create connection object-oriented style - below:

$mysqli = new mysqli("databaseserver", "username", "password", "databasename); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -