Jump to content

PHP odbc for loop help!!


Merlin1

Recommended Posts

Hey.

Im working on a social networking site at the moment and im using Access database and connecting to it via odbc.

 

The problem i have is that a users friends are stored in a text file and i need to pull all of that users friends out from the database and display their username and image.

 

Here is my code

 

<table cellpadding='0' cellspacing='0' width='100%'>

<td valign='middle' class='subHead'>Friends ( ) - View All</td>

<tr>

<td class='subContent'><br />

<?php

$userName = odbc_result($users_rs,'Username');

$friends = file('../'.$userName.'/friends/friends.txt');

$friendCount = count($friends);

echo'<table width="100%">';

for ($f = 0;$f<count($friendCount);$f++){

$fs = odbc_exec($conn,"SELECT * FROM Users WHERE Email='".$friends[$f]."'");

echo '<td class="friendBox0">';

echo '<a href="../'.odbc_result($fs,'Username').'"><img border="0" src="'.odbc_result($fs,'thumbPicture').'" /></a></td><td class="friendBox"><a href="../'.odbc_result($fs,'Username').'">';

echo odbc_result($fs,'Name');

echo '</a></td><tr>';

if($f == 6){

break;

}

 

}

echo'</table>';

?>

</td>

</table>

 

The problem is, it only works when there is one user in the text file, if theres more nothing comes up. Could this be because i am re-using the variable that excecutes the SQL? or am i missing something completly?

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/113138-php-odbc-for-loop-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.