echo code problem

Hi All,

I’ve created a login script that pulls the following info from the users table;-
Username, client_id

It sucessfully works and I can echo the client_id with no issues. My problem is when I try to use this echo function elsewhere, I’ve tried several options but the only one that works is if I enter the client id as a number i.e “1” rather than echo client_id.

Heres part of my code;-
[php]include ‘…/include/database-connect.php’;
$pdo = Database::connect();
$sql = ‘SELECT * FROM fms_tbl_suppliers WHERE client_id= 1 ORDER BY name ASC’;
foreach ($pdo->query($sql) as $row) {[/php]

Again any help is very appreciated… it will let me sleep at night!!!

Feel free to provide the relevant code so someone can help you.

Hi Kevin,

My code is as follows;-
[php] <?php
include ‘…/include/database-connect.php’;
$pdo = Database::connect();
$sql = ‘SELECT * FROM fms_tbl_suppliers WHERE client_id= 1 ORDER BY name ASC’;
foreach ($pdo->query($sql) as $row) {
echo ‘

’;
echo ‘’. $row[‘name’] . ‘’;
echo ‘’. $row[‘tel’] . ‘’;
echo “<a href='mailto:”. $row[‘email’]."’>". $row[‘email’]."";
echo ‘’. $row[‘category’] . ‘’;
echo ‘’. $row[‘ce’] . ‘’;
echo ‘’. $row[‘ce_class’] . ‘’;
echo ‘’. $row[‘iso’] . ‘’;
							if($row['tm_sat']=='2+') 
     							echo "<td><span class='label label-primary'>".$row['tm_sat']."</span></td>"; 

 							else if($row['tm_sat']=='Monitor')
     							echo "<td><span class='label label-warning'>".$row['tm_sat']."</span></td>"; 

							else if($row['tm_sat']=='Do Not Use')
     							echo "<td><span class='label label-danger'>".$row['tm_sat']."</span></td>"; 

						   	echo '<td width=50>';
						   	echo '<a href="read.php?id='.$row['id'].'"><i class="fa fa-eye "></i></a>';
						   	echo '&nbsp;';
						   	echo '<a href="update.php?id='.$row['id'].'"><i class="fa fa-pencil "></i></a>';
						   	echo '&nbsp;';
						   	echo '<a href="delete.php?id='.$row['id'].'"><i class="fa fa-trash "></i></a>';
						   	echo '</td>';
						   	echo '</tr>';
				   }
				   Database::disconnect();
				  ?>[/php]

I am not used to pdo coding so please bear with me, its the $sql line that I am struggling with, the “= 1” should be $login_client_id but I keep getting blanks pages.

Any any help is appreciated.

Download my PDO bumpstart database from my signature link and get familiar with how its done correctly.

Sponsor our Newsletter | Privacy Policy | Terms of Service