php - Sql failing to calling fields correctly -
the php/sql calling this:
<?php // filter our input. $pid = filter_input(input_get, 'pid', filter_sanitize_number_int); if(!$pid) { echo "no pid specified."; exit; } $username = "##"; $password = "####"; $pdo = new pdo('mysql:host=localhost;dbname=###', $username, $password); $pdo->setattribute( pdo::attr_errmode, pdo::errmode_exception ); $sth = $pdo->prepare(' select name, lname, fname, picpath, email department, professor pid = ? ;'); $sth->execute(array( $pid ));
the other php code:
if($sth->rowcount() > 0) { $row = $sth->fetch(pdo::fetch_assoc); <div class='professor_pic'> <img src='{$row['picpath']}' /> </div><!-- /professor_pic --> <div class='professor_desc'> <span class='one' style='float:left; padding:5px 0 0 5px;'><strong>department:</strong> {$row['name']} </span><br> } else { echo "no results."; } unset($sth); ?>
why arent these 2 fields 'picpath' , 'name' being pulled?? not throwing error. above 2 db fields:
i suspect have numerous errors initial sql query.
i suggest read on mysql join. considering understood how query supposed run try this:
select d.name, p.lname, p.fname, p.picpath, p.email professor p join department d on d.did = p.did p.pid = ?
Comments
Post a Comment