Jump to content

not echoing fields from profile table


MikeDXUNL

Recommended Posts

<?php
$result = mysql_query("SELECT * FROM members LEFT JOIN profile ON members.id = profile.id WHERE members.id='$id'") or die('Query failed: ' . mysql_error());
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
 echo $line['displayname']. "</td>";
      echo "</tr><tr><td>";
      echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
      echo "<tr><td align=\"center\" width=\"20%\">";
      echo "<img src=\"userphotos/" .$line['photo']. "\">"; ?>
</td>
    <td valign="top" width="100%">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="quote"><?php
echo "Quote: " .$line['quote']. "</td></tr><tr><td>";
	echo "Name: " .$line['name']. "<br />";
echo "Location: " .$line['location']. "<br />";
echo "Gender: " .$line['gender']. "<br />";
echo "Status: " .$line['status']. "<br />";
echo "Website: <a href=\"" .$line['website']. "\" target=\"_new\">" .$line['website']. "</a><br />";
echo "Job:" .$line['occupation']. "<br />"; }?>

 

 

alright. well it will echo everything from the members table, but nothing from the profile table. and have no clue why? :(

could someone please help?

Link to comment
https://forums.phpfreaks.com/topic/38867-not-echoing-fields-from-profile-table/
Share on other sites

It might be that there is something wrong with your join (members.id = profile.id) shouldn't it be something like members.id = profile.memberid? and i would not recommend a left join in this case because a member should always have at least one profile (which is a one to many relation from the members table). Hope this helps.

lol you are right, i got to thinking and should move all the profile-related stuff to the profile table. i started the tables without thinking and put stuff like "hobby, photo, job" in the member table

 

so i will probably re-write it tonight, thank though :)

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.