Jump to content

yanaho

New Members
  • Posts

    2
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

yanaho's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I love you guys,thanks thorpe may your deeds not go unrewarded.  =)
  2. Hi all! this is my first post so please go easy. What I'm doing is simple.  But for the life of me I can't do it.  I hope someone can help. I have a class called database, in this class is a function which i want to return a 2 dimensional array, filled with rows from my database table.  I want to call this function from another page and have the html table populated with the information.  Why is this so hard you ask?  well I've spent hours looking on the net and nobody seems to call such a function.  All examples are coded on the page where the html table is being displayed, which i find very messy. I'm guessing the function would look something like: function getShows($date){       $q = "SELECT * FROM ".TBL_SHOWS." WHERE date = '$date'";       $result = mysql_query($q, $this->connection);       /* Error occurred */       if(!$result || (mysql_numrows($result) < 1)){         return NULL;       }       /* Return result array */       $dbassoc = mysql_fetch_assoc($result);       return $dbassoc;   } and I'm guessing the code to display would look something like $req_shows = $database->getShows(date); foreach($req_shows AS $id=>$info) {   echo '<tr><td>'.$info['type'].'</td>     <td>'.$info['time'].'</td>     <td>'.$info['artistid'].'</td>     <td>'.$info['genre'].'</td>     <td>'.$info['location'].'</td></tr>'; } but this doesnt work along with a thousand other things i have tried as my knowledge of php is kinda weak.  Please if you can find the time I'm sure you must have all written something like this at some time.  I guess the biggest problem is I dont know what the function above is actually returning. 1 row or all rows, if all rows then I guess step one is complete, if only 1 row how can i make the function return multiple, or am I wasting my time having it return anything and just write the script on the page displaying the info(which is easy enough as there is code everywhere showing how) Once I have this figured I'm all set. Thanks in advance
×
×
  • 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.