TeddyKiller Posted May 3, 2010 Author Share Posted May 3, 2010 I was just about to post that I had an error, then I thought.. ah damn, Ken2k7 picked up the "IN =" I forgot to change it. I changed it to an = . Thanks for reminding me mjdamato. It works! Long struggle understanding this, but I got it to work. All the variables do as I wanted them too. mjdamato, I changed the * to the nessecary collums (I needed them all) although I went by roopurts post. Thanks guys! Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted May 3, 2010 Author Share Posted May 3, 2010 $query = "SELECT u.username, u.avatar, us.* FROM `users` AS u JOIN `user_status` AS us ON u.id = us.user_id JOIN `friends` AS f ON us.user_id = f.friend_id WHERE f.user_id = '$user->id' ORDER BY us.posted DESC"; $result = mysql_query($query) or DIE("Query:<br />$query<br />Error:<br />".mysql_error()); $first_record = true; echo "<table>\n"; while($row = mysql_fetch_assoc($result)) { if($first_record) { echo "<tr>\n"; foreach($row as $header=>$value) { echo "<th>{$header}</th>\n"; } echo "</tr>\n"; $first_record = false; } echo "<tr>\n"; foreach($row as $value) { echo "<td>{$value}</td>\n"; } echo "</tr>\n"; } echo "</table>\n"; Where would my echo be.. Whats the advantage of the $first_record, too? I don't understand. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted May 3, 2010 Share Posted May 3, 2010 your echo would be the third from the bottom, and he is using $first_record to say that "if this is the first record, echo out the field names at the top of the table, otherwise just fill in the values". Effectivly that's a full substitute code he's got there. Quote Link to comment Share on other sites More sharing options...
Psycho Posted May 3, 2010 Share Posted May 3, 2010 your echo would be the third from the bottom, and he is using $first_record to say that "if this is the first record, echo out the field names at the top of the table, otherwise just fill in the values". Effectivly that's a full substitute code he's got there. Yeah, what he said. The code I provided was only to use for illustrative purposes to see the data being returned from the query to ensure it is what you are wanting/expecting. I leave it up to you to output the results how you need them. Quote Link to comment Share on other sites More sharing options...
TeddyKiller Posted May 3, 2010 Author Share Posted May 3, 2010 your echo would be the third from the bottom, and he is using $first_record to say that "if this is the first record, echo out the field names at the top of the table, otherwise just fill in the values". Effectivly that's a full substitute code he's got there. Yeah, what he said. The code I provided was only to use for illustrative purposes to see the data being returned from the query to ensure it is what you are wanting/expecting. I leave it up to you to output the results how you need them. Yeah. I thought that, as it looked pretty.. strange to output an echo like mine. Everythings working now anyway. Thanks. Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted May 3, 2010 Share Posted May 3, 2010 For my part your welcome, keep up the good fight Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.