13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Implementing User Functions<br />

715<br />

Listing 30.10 load_list_info()Function from mlm_fns.php—This Function<br />

Builds an Array of List Information<br />

function load_list_info($listid) {<br />

if(!$listid) {<br />

return false;<br />

}<br />

if(!($conn=db_connect())) {<br />

return false;<br />

}<br />

$query = "select listname, blurb from lists where listid =<br />

'".$listid."'";<br />

$result = $conn->query($query);<br />

if(!$result) {<br />

echo "Cannot retrieve this list.";<br />

return false;<br />

}<br />

$info = $result->fetch_assoc();<br />

$query = "select count(*) from sub_lists where listid =<br />

'".$listid."'";<br />

$result = $conn->query($query);<br />

if($result) {<br />

$row = $result->fetch_array();<br />

$info['subscribers'] = $row[0];<br />

}<br />

$query = "select count(*) from mail where listid = '".$listid."'<br />

<strong>and</strong> status = 'SENT'";<br />

$result = $conn->query($query);<br />

if($result) {<br />

$row = $result->fetch_array();<br />

$info['archive'] = $row[0];<br />

}<br />

return $info;<br />

}

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!