Jump to content

tmfl

Members
  • Posts

    17
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

tmfl's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks wildteen88.....works perfectly.....
  2. ah ok.....well thanks v much for looking at it........i've been looking around for a while today on code that prints the result set top down and then left to right.....yours was by far the best i've seen.... just another quick question for you...i've never seen the @ symbol used like this before..... @$rows[$j] .= ' <td class="member">'.$data."</td>"; i'm googling now to see what it means......maybe you could explain too.... thanks again for all your help.... a
  3. ok... the code is as follows... $num_results = mysql_num_rows($res); $num_cols = 4; $num_rows_decimal = $num_results / $num_cols; $num_rows = ceil($num_rows_decimal); $rows = array(); $j = 1; while($row = mysql_fetch_assoc($res)) { $data = $row['firstname'].' '.$row['lastname']; @$rows[$j] .= ' <td class="member">'.$data."</td>"; if($j == $num_rows) $j = 0; $j++; } echo '<table class="losfinal"> <thead> <tr> <th colspan="4">Players</th> </tr> </thead>'; foreach($rows as $row) { echo " <tr>" . $row . " </tr>"; } echo '</table>'; The live page where its running is http://www.horeswoodgaa.com/membership.php and as i said it works fine in Firefox but not in IE8 or Chrome 10 (all on Windows) Go to the 2011 Membership table and cells and border is missing. thanks for your help. a
  4. I did....and didnt really get any replys for a solution...... if you have one could you post here then http://www.phpfreaks.com/forums/index.php?topic=331778.0 thanks a
  5. Just did some further testing with this and it doesnt render the table correctly on IE8 or Chrome 10....works fine in Firefox tho!....back to the drawing board.... anyone ? ta..... a
  6. Hi, I've implemented this on Firefox and it works perfectly but it does not render the table correctly on IE8 and Chrome 10 (missing blank tds and the td border so table looks incomplete). Has anyone else come across this problem and found a solution ? thanks in advance a
  7. thanks for your help fugix but I got another piece of code from the forums here http://www.phpfreaks.com/forums/index.php?topic=211937.msg965544#msg965544 it works a treat... thanks again
  8. Thanks for the reply fugix, I've got a membership list which I am returning I want my table to have 4 columns and, say, 20 rows at the moment... Member 1 Member 3 Member 2 Member 4 .. Member 20 Member 40 I'm not sure how to open the row, populate the 1st table cell then close the row open the 2nd row etc then when I get to the 21st member I will have to re-open the first row and populate the 2nd cell.... I'm not sure also by what you mean when u say order by odd/even ids thanks a
  9. Hi, The code for displaying a results set in multiple columns (http://www.phpfreaks.com/forums/index.php?topic=95426.0) works really well and displays 1 2 3 4 5 6 7 8 Does anyone know how to change so it displays as 1 3 5 7 2 4 6 8 Any help would be greatly appreciated thanks a
  10. Thanks for the replies. So you're saying there is no real requirement for a validation class ? I should just validate the form variables before I pass to the User object login method ? I'm still a bit confused over what the constructor will do too....if I use this class to create a user it will have maybe 3 or more parameters but when a user logs in it will have only 2..... eg. What should I do when I'm declaring the constructor in this situation ? Many thanks in advance for anyone providing help here....
  11. Hi, I've always used PHP code in my websites in a procedural manner as I come from a html/css background. Now that I want to do projects with more complexity I'm thinking I need to approach development in a more Object Oriented fashion. My question is more a theoretical one. I'm creating a User class and I'm not sure on what is the best practise for putting my functions etc. and where to call them. My project will have 2 different users (Admin & End User) so is it correct to say that the User class should encapsulate all the functions of both of these users ? By that I mean create/delete/modify user, login & change password/forgotten password functionality rather than having a seperate Login class Should I only call the database functions within these methods of the user class as opposed to calling them on the php page where the form data is posted ? For example, if a user logins in and when the form data is posted I currently open a connection, validate data, run the query. In an OO approach would I have just one User class method thats relevant to a particular page functionality ? Say, in pseudo code, for handling a login request loginRequest.php include User class try { create new user User(); User::login(); } catch Exception() and should my User class look something like this class.User.php include DBase class class User { var name, var email, var password, function validateInput (email, password) { if (!valid input) throw Exception else return true } function login (email, password){ try { database connection validateInput(); sql to see if user exists and login } catch Exception } } Apologies for this being a bit long winded! thanks tmfl
  12. Thanks for the reply... At the moment the form I'm using has a dropdown for hours and a dropdown for minutes.... I guess converting it on the way in to minutes is the way you'd recommend then yeah ? thanks again tmfl
  13. Hi, I'm inserting hours and minutes per user into a database where they have their own fields. (userid, hours, mins) I've a small issue when displaying the data. When I run my query I sum the total hours and minutes per user which results in data such as the following userid1 - 2 hours 15 mins userid2 - 1 hour 100 mins The query orders by hours and then mins desc When I'm displaying the data (as I'm looping through the results array) I perform a calculation to convert the mins to hours so it now reads userid1 - 2 hours 15 mins userid2 - 2 hours 40 mins so the webpage displays userid1 first when i want userid2 to be the first record displayed (Hours desc) Can anyone recommend a solution to this ? Will I need to create another table and update it as hours and minutes are being entered and display results from that table instead ? Can I order the data after I carry out the mins to hours calculation ? many thanks in advance for any suggestions.... tmfl
  14. Worked a treat thanks! Now on to the next stage!...storing the hours and minutes....not sure i know whats the best way to approach this using the above code....reckon i'll be posting again! thanks again....
  15. Hi, I'm having problems retrieving the values from a form posting without getting a warning My form records playername, hours played and minutes played <li id="input1" style="margin-bottom:4px;" class="clonedInput"> Name: <select name="player[1][userid]" id="player[1][userid]" class="playerInput" style="width: 7em;" > <option value=""></option> <?php while($row = mysql_fetch_array($sql)) { echo '<option value="'.stripslashes($row['userid']).'">'.stripslashes($row['name']).'</option>'; } mysql_data_seek($sql,0); ?> </select> <select name="player[1][hours]" id="player[1][hours]"> <option value="">Hours</option> <option value=""></option> <?php for($x = 0; $x <= 23; $x++ ) { echo '<option value="'.$x.'">'.$x.'</option>'; } ?> </select> <select name="player[1][minutes]" id="player[1][minutes]"> <option value="">Minutes</option> <option value=""></option> <?php for($y = 15; $y <= 59; $y+=15) { echo '<option value="'.$y.'">'.$y.'</option>'; } ?> </select> </li> I use some javascript to create new players as necessary so every player has a userid, hours, minutes played... After posting the query string looks like this /cLeagueHandler.php?player[1][userid]=1&player[1][hours]=3&player[1][minutes]=15&player[2][userid]=3&player[2][hours]=6&player[2][minutes]=45&submit=Save+Points player1 userid = 1 hours = 3 minutes = 15 player2....... The code i'm using to access the values is print_r ($_GET); // test display form values foreach ($_GET as $key => $value) { echo '<br/>'.$key.'<br/> '; foreach ($value as $iKey => $iValue) { // Line 72 foreach ($iValue as $xKey => $xValue) { echo " The $xKey for Player $iValue is $xValue <br/>"; } } } The above code displays Array ( [player] => Array ( [1] => Array ( [userid] => 1 [hours] => 3 [minutes] => 15 ) [2] => Array ( [userid] => 3 [hours] => 6 [minutes] => 45 ) ) [submit] => Save Points ) player The userid for Player Array is 1 The hours for Player Array is 3 The minutes for Player Array is 15 The userid for Player Array is 3 The hours for Player Array is 6 The minutes for Player Array is 45 submit Warning: Invalid argument supplied for foreach() in .................cLeagueHandler.php on line 72 Line 72 is foreach ($value as $iKey => $iValue) { If anyone could help me with this it would be great appreciated.......I want to be able to build and sql string to Insert a players id, hours, minutes into a database......(obviously not incl the submit value!) Maybe this is not even the best way of approaching this.....I'm quiet new to PHP so apologies if this is long winded...I'm trying to give as much info as possible.... thanks in advance tmfl
×
×
  • 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.