fizzzgigg Posted December 30, 2010 Share Posted December 30, 2010 I tried doing functions and all that... I am just can't seem to figure it out. If someone could help me or point me in the right direction, that would be awesome! I need this following script: <?PHP include('functions.php'); $query = "SELECT DISTINCT name FROM homework WHERE uid='$loggedin' ORDER BY id ASC"; $result = mysql_query($query); while ($myrow = mysql_fetch_array($result)) { echo $myrow['name']."<br> "; } ?> That script needs to be executed in the sidepanel where the word "hello" is in this script: <?PHP include('functions.php'); $linktent = '<div class="titler">Your Pictures</div><div class="contentm">'.$data[index].'</div>'; $excess = '<div class="titlerex">Past Assignments</div><div class="contentmex">'."hello".'</div>'; echo getlyt($title, $linktent, $excess); Any help would be greatly appreciated. Adam Quote Link to comment https://forums.phpfreaks.com/topic/222964-i-need-this-here/ Share on other sites More sharing options...
fizzzgigg Posted December 30, 2010 Author Share Posted December 30, 2010 UPDATE: I have it fixed but not completely. There should be two rows populated but I am getting one. <?PHP include('functions.php'); $query = "SELECT DISTINCT name,pid FROM homework WHERE uid='$loggedin' ORDER BY id ASC"; $result = mysql_query($query); while ($myrow = mysql_fetch_array($result)) { $display = "<a href=myphotos.php?pid=".$myrow['pid'].">".$myrow['name']."<br>"; } $title = 'Light Graspers Certification'; $linktent = '<div class="titler">Your Pictures</div><div class="contentm">'.$data[index].'</div>'; $excess = '<div class="titlerex">Past Assignments</div><div class="contentmex">'.$display.'</div>'; echo getlyt($title, $linktent, $excess); But it works just fine in test.php file by itself... as in I get the correct results. Any guesses? <?PHP include('functions.php'); $query = "SELECT DISTINCT name,pid FROM homework WHERE uid='$loggedin' ORDER BY id ASC"; $result = mysql_query($query); while ($myrow = mysql_fetch_array($result)) { echo "<a href=myphotos.php?pid=".$myrow['pid'].">".$myrow['name']."<br> "; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/222964-i-need-this-here/#findComment-1152852 Share on other sites More sharing options...
fizzzgigg Posted December 30, 2010 Author Share Posted December 30, 2010 I added some more information to the database to increase the results I am still only getting the first result to display. I don't know why it works by itself, but doesn't when I intergrate it into the site. Anyone have some ideas? Adam Quote Link to comment https://forums.phpfreaks.com/topic/222964-i-need-this-here/#findComment-1152855 Share on other sites More sharing options...
QuickOldCar Posted December 30, 2010 Share Posted December 30, 2010 $display = "<a href=myphotos.php?pid=".$myrow['pid'].">".$myrow['name']."<br>"; You did not echo the result for display. echo $display; Quote Link to comment https://forums.phpfreaks.com/topic/222964-i-need-this-here/#findComment-1152858 Share on other sites More sharing options...
trq Posted December 30, 2010 Share Posted December 30, 2010 Where is $loggedin defined? Quote Link to comment https://forums.phpfreaks.com/topic/222964-i-need-this-here/#findComment-1152859 Share on other sites More sharing options...
fizzzgigg Posted December 30, 2010 Author Share Posted December 30, 2010 QuickOldCar: I put echo all throughout the script and I constantly received errors? Besides isn't the script being echoed in the very end? $excess = '<div class="titlerex">Past Assignments</div><div class="contentmex">'.$display.'</div>'; echo getlyt($title, $linktent, $excess); It needs to be in the $excess area due to the div placement. thorpe: $loggedin is stored in functions.php Quote Link to comment https://forums.phpfreaks.com/topic/222964-i-need-this-here/#findComment-1152864 Share on other sites More sharing options...
QuickOldCar Posted December 30, 2010 Share Posted December 30, 2010 But not in the while loop it's not, and that brings you the multiple results from mysql query. Quote Link to comment https://forums.phpfreaks.com/topic/222964-i-need-this-here/#findComment-1152866 Share on other sites More sharing options...
trq Posted December 30, 2010 Share Posted December 30, 2010 QuickOldCar is right. You need to concatenate the results together. (note the .= operator) $display .= "<a href='myphotos.php?pid={$myrow['pid']}'>{$myrow['name']}</a><br>"; Your html wasn't valid either so I fixed that as well. Quote Link to comment https://forums.phpfreaks.com/topic/222964-i-need-this-here/#findComment-1152868 Share on other sites More sharing options...
fizzzgigg Posted December 30, 2010 Author Share Posted December 30, 2010 OMG! 8) Thank you. I have been working on this all day and I feel like such a noob! Thank you guys for your help. I have it working now. On to the next thing... Quote Link to comment https://forums.phpfreaks.com/topic/222964-i-need-this-here/#findComment-1152872 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.