MDanz Posted August 26, 2009 Share Posted August 26, 2009 lol i did it wrong and did if user logged in, which displays all entries in the database. what i wanted was display 'username' entries. The code below is what i have to display. everything there is correct. What do i add on to make it display only a certain users entries? i'm guessing this whole bunch of code in a while loop? can i have an example.. $query_result = mysql_query("SELECT * FROM `castack`") or die("Error");; $total = mysql_num_rows($query_result); $row_count = ceil($total / ; echo "<table>"; // loop through rows for($row = 0; $row < $row_count; $row++) { // output start of row echo "<tr>"; // loop through columns for($col = 0; $col < 8; $col++) { // grab next row $row_data = mysql_fetch_assoc($query_result); if($row_data != FALSE) { $stackname = $row_data['name']; echo "<td><a href='http://www.example.com/search.php?search=$stackname' style='text-decoration: none';><table border='0' celpadding='0' cellspacing='0'> <tr> <td width='101px' height='101px' background='Stacks/template.jpg' VALIGN='middle'> <font color=black font size=3 font face=Arial><center><b>$stackname</b></center></font></td> </td> </tr> </table></a></td>"; } else { // no data left in our array // output a blank box to finish table echo "<td> </td>"; } } // close row echo "</tr>"; } // close table echo "</table>"; Link to comment https://forums.phpfreaks.com/topic/171907-help-on-code-display-one-users-details/ Share on other sites More sharing options...
MDanz Posted August 26, 2009 Author Share Posted August 26, 2009 :'( help i thought i had it right but got it wrong... Link to comment https://forums.phpfreaks.com/topic/171907-help-on-code-display-one-users-details/#findComment-906758 Share on other sites More sharing options...
AngelicS Posted August 26, 2009 Share Posted August 26, 2009 To only show a certain persons data, you'll need to add "WHERE - W3Schools" in your mysql query. Then just do a $user_data=mysql_fetch_array($mysql_query); Then if you want to echo the users name, you can do it like this: echo $user_data['name']; The "name" is a name column that you get from your database. Link to comment https://forums.phpfreaks.com/topic/171907-help-on-code-display-one-users-details/#findComment-906771 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.