Jump to content

display multiple records from mysql on page


macman73

Recommended Posts

Hope someone here can help

I am no PHP expert so please excuse me i took a logon/user mangement script that someone else designed and have been adding to it since and been doing OK but i am stuck on this.

I have a userinfo page that displays data to the user that is relevent to them

 

this is the section of the userinfo file that i am working on

 

user info.php

/* Display requested user information */
$req_user_info = $database->getUserInfo($req_user);
$req_game_a = $database->getGameA($req_user);

/* Username */
echo "<b>Username: ".$req_user_info['username']."</b><br>";

/* Email */
echo "<b>Email:</b> ".$req_user_info['email']."<br>";

/* Game A */
echo "<b>Weekly Game:</b> ".$req_game_a['comment_text']."<br>";

 

its the last line here that i am specifically working with(the call for the "comment_text" data

as you can see on line 5 i am calling a function from a database.php file which is show below

 

datbase.php
    */
   function getGameA($username){
      $q = "SELECT * FROM ".TBL_COMMENT." WHERE username = '$username'";
      $result = mysql_query($q, $this->connection);
      /* Error occurred, return given name by default */
      if(!$result || (mysql_numrows($result) < 0)){
         return NULL;
      }
      /* Return result array */
      $dbarray = mysql_fetch_array($result);
      return $dbarray;
   }
   
   /**

 

My problem is this it will only display the last record that the user entered

I dont know if i am doing it right but a user enters information into this table and they may have several entrys against there username and i am trying to diplay all the users entrys.

 

i hope i have been clear in my problem and that someone can help

 

i have trawled the net for a couple of days and tried various changes but am getting nowhere

 

I have a headache  ???

 

thanks in advance

 

macman73

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.