Jump to content

aebstract

Members
  • Posts

    1,105
  • Joined

  • Last visited

Everything posted by aebstract

  1. $query2 = mysql_query(" SELECT registrations.firstname, participants.eventid, registrations.lastname, participants.q1, participants.q2, participants.q3, participants.q1s, participants.q2s, participants.q3s, participants.q1rt, participants.q2rt, participants.q3rt, participants.regid FROM participants INNER JOIN registrations ON registrations.id = participants.regid WHERE participants.eventid = $_GET[event] AND registrations.class = '$var'") or DIE(mysql_error()); if(mysql_num_rows($query)!=0){ $indexL[$var] = array(); $indexH[$var] = array(); while($r2=mysql_fetch_array($query2)) { $var2 = substr($var,0,4); if ((($r2[q1] + $r2[q1rt]) < $var2) && (($r2[q2] + $r2[q2rt]) < $var2) && (($r2[q3] + $r2[q3rt]) < $var2)){ $indexL[$var][] = array('firstname' => "$r2[firstname]", 'lastname' => "$r2[lastname]", 'q1' => "$r2[q1]", 'q2' => "$r2[q2]", 'q3' => "$r2[q3]", 'regid' => "$r2[regid]", 'eventid' => "$r2[eventid]"); } else { $indexH[$var][] = array('firstname' => "$r2[firstname]", 'lastname' => "$r2[lastname]", 'q1' => "$r2[q1]", 'q2' => "$r2[q2]", 'q3' => "$r2[q3]", 'regid' => "$r2[regid]", 'eventid' => "$r2[eventid]"); } } } $countH = count($indexH[$var]); $countL = count($indexL[$var]); foreach ( $indexL[$var] as $val ){ foreach ( $val as $final_val ){ $content .= sprintf("%s <br/>", $final_val['firstname']); } }
  2. I get the same results as what I posted to atomic.
  3. I guess they got changed to bullets, it's indexes [0] [1] etc, none of them go over 1. Here is the full array for $indexL: I put spaces so it wouldn't change. I plan on doing other things with the values in the array, I was just trying to get a grasp on how to control the values and so far I can't get the value. teamatomic: When I try that code, I get this output: 4.70 M H 4 4 4 1 1 5.30 Index A G 5 5 5 1 1 R C 5 5 5 1 1 6.00 Index 7.00 Index T M 6 6 6 8 1
  4. foreach ( $indexL[$var] as $val ){ foreach ( $val as $key=>$final_val ){ $content .= "$key[firstname]"; } $content .= "<br>"; } Here are the results from a print_r($indexL[$var]); My output looks like: flqqqre flqqqre flqqqre flqqqre I tried to use $final_val[firstname] but it gave me odd results too.
  5. Well, the code that I just pasted is the exact copy of what I ran to get the error.
  6. Okay I have 2 databases, almost similar. One is more up to date with newer information, a lot of the information is the same though. I accidentally wrote over an entire column in one of my tables. I need to update it with my old database info from that column. The other columns need to be left alone though. I did a simple select q1, id from table to get all the results and exported it out but it gave it to me in the form of an insert, obviously. (coming out of phpmyadmin) Anything simple to fix my problem?
  7. I think this was what I was missing: $indexL[$var][] = array("$r2[firstname]", "$r2[lastname]", "$var"); Just the extra [], results are looking better. Maybe something I can work with.
  8. I've got something I've been working on and have tried 2 different methods. One using a different database setup and another using these arrays, which I can't get them to set correctly. I'm sitting here just wasting time because I can't figure it out and no one has an answer. Though, I'm basically stuck here until I do figure it out. I don't get why this: $query2 = mysql_query(" SELECT registrations.firstname, participants.eventid, registrations.lastname, participants.q1, participants.q2, participants.q3, participants.q1s, participants.q2s, participants.q3s, participants.q1rt, participants.q2rt, participants.q3rt, participants.regid FROM participants INNER JOIN registrations ON registrations.id = participants.regid WHERE participants.eventid = $_GET[event] AND registrations.class = '$var'") or DIE(mysql_error()); if(mysql_num_rows($query)!=0){ $indexL[$var] = array(); while($r2=mysql_fetch_array($query2)) { $indexL[$var] = array("$r2[firstname]", "$r2[lastname]", "$var"); } } Is only setting this: Array ( [4.70 Index] => Array ( [0] => Jeff [1] => Wilkerson [2] => 4.70 Index ) [5.30 Index] => Array ( [0] => Ronnie [1] => Clayton [2] => 5.30 Index ) [6.00 Index] => Array ( [0] => Ricki [1] => Blackwell [2] => 6.00 Index ) [7.00 Index] => Array ( [0] => Adam [1] => Stratton [2] => 7.00 Index ) ) Even though this isn't what I'm going for, it's still a very basic array just to see what is up. I'm only returning one result per class, but my query doesn't have that limit on it?
  9. Erm, getting back some odd results: $query2 = mysql_query(" SELECT registrations.firstname, participants.eventid, registrations.lastname, participants.q1, participants.q2, participants.q3, participants.q1s, participants.q2s, participants.q3s, participants.q1rt, participants.q2rt, participants.q3rt, participants.regid FROM participants INNER JOIN registrations ON registrations.id = participants.regid WHERE participants.eventid = $_GET[event] AND registrations.class = '$var'") or DIE(mysql_error()); if(mysql_num_rows($query)!=0){ while($r2=mysql_fetch_array($query2)) { $var2 = substr($var, 0, 4); if (($r2[q1] < $var2) && ($r2[q2] < $var2) && ($r2[q3] < $var2)) { $indexqpL[$var] = array(array(regid => "$r2[regid]", firstname => "$r2[firstname]", lastname => "$r2[lastname]", eventid => "$r2[eventid]", q1 => "$r2[q1]", q2 => "$r2[q2]", q3 => "$r2[q3]", )); } else { $indexqpH[$var] = array(array(regid => "$r2[regid]", firstname => "$r2[firstname]", lastname => "$r2[lastname]", eventid => "$r2[eventid]", q1 => "$r2[q1]", q2 => "$r2[q2]", q3 => "$r2[q3]", )); } } } echo "<pre>"; var_dump($indexqpH); echo "</pre>"; Not what I'm after, almost like stabbing in the dark over here but I'm gonna keep trying until I figure something out (or get a little help?)
  10. $query2 = mysql_query(" SELECT registrations.firstname, participants.eventid, registrations.lastname, participants.q1, participants.q2, participants.q3, participants.q1s, participants.q2s, participants.q3s, participants.q1rt, participants.q2rt, participants.q3rt, participants.regid FROM participants INNER JOIN registrations ON registrations.id = participants.regid WHERE participants.eventid = $_GET[event] AND registrations.class = '$var'") or DIE(mysql_error()); if(mysql_num_rows($query)!=0){ while($r2=mysql_fetch_array($query2)) { $var2 = substr($var, 0, 4); if (($r2[q1] < $var2) && ($r2[q2] < $var2) && ($r2[q3] < $var2)) { $indexqpL = array($var => array(regid => "$r2[regid]", firstname => "$r2[firstname]", lastname => "$r2[lastname]", eventid => "$r2[eventid]", q1 => "$r2[q1]", q2 => "$r2[q2]", q3 => "$r2[q3]", )); } else { $indexqpH = array($var => array(regid => "$r2[regid]", firstname => "$r2[firstname]", lastname => "$r2[lastname]", eventid => "$r2[eventid]", q1 => "$r2[q1]", q2 => "$r2[q2]", q3 => "$r2[q3]", )); } } } echo "<pre>"; var_dump($indexqpH); echo "</pre>"; This query resulted in these results: That's 1 person from each class, but there are a lot more than that. 4.70 has 10 people alone. I guess I'm not combining them and it keeps overwriting? I'm wanting to place each of those results IN TO the "class" array as its own index, hmm.. maybe I just need an extra array in the mix?
  11. Basically, the structure I'm trying to get is: $var = 'class name here'; $indexqpH[$var][#][info] info being firstname, lastname, etc. The number to be the array index for each of said info. It's in a loop where $var will be set to 4 different things, so I should end up with 4 arrays that I can look at based on class.
  12. I just had it as an example of how I might use the information. while($r2=mysql_fetch_array($query2)) { if (($r2[q1] < 4.70) && ($r2[q2] < 4.70) && ($r2[q3] < 4.70)) { $indexqpH = array( '$var' => array(array(regid => "$r2[regid]", firstname => "$r2[firstname]", lastname => "$r2[lastname]", eventid => "$r2[eventid]", q1 => "$r2[q1]", q2 => "$r2[q2]", q3 => "$r2[q2]", ))); } else { $indexqpL = array( '$var' => array(array(regid => "$r2[regid]", firstname => "$r2[firstname]", lastname => "$r2[lastname]", eventid => "$r2[eventid]", q1 => "$r2[q1]", q2 => "$r2[q2]", q3 => "$r2[q2]", ))); } } } $count1 = count($indexqpH[$var]); $count2 = count($indexqpL[$var]); for ($i = 1; $i <= $count1; $i++) { $content .= "$indexqpH[$var][$i][firstname] $indexqpH[$var][$i][lastname]<br />"; } I think I'm getting an endless loop here, when I refresh the page after uploading this it just sits and loads.
  13. Thanks, That one rang a little bell in my head. I will try that. If anyone have any other answers. Please write them. I really appreciate it. Nope, that's how you should do it.
  14. $indexqpH[] = array(regid => "$r2[regid]", firstname => "$r2[firstname]", lastname => "$r2[lastname]", eventid => "$r2[eventid]", q1 => "$r2[q1]", q2 => "$r2[q2]", q3 => "$r2[q2]", ); This get's me an array that I should be able to call out by using $indexqpH[1][q1], $indexqpH[1][q2], etc. Right? I have one more variable I would like to set, somehow make it another dimension deep (can do that okay) but want to name it, not sure how? I know this is simple. So that I can have: $indexqpH[class1][1][q1] $indexqpH[class2][1][q1] $indexqpH[class2][2][q1] $indexqpH[class1][2][q1] $indexqpH[class3][1][q1] So I can do something similar to this.
  15. The code you posted, won't return a result like this: 123 4.764.784.72 4.68 4.734.75 I can see it checking each one or whatever but don't see how it brings the results based on the three rounds for each. I might be looking at it wrongly. I set up a separate table just for these that are done in this way. I have id, regid, eventid, round, et, rt, mph. regid = registered users id eventid = event id round = which round, possible options being: q1, q2, q3 et = decimal rt = decimal mph = decimal The round time should actually be et+rt, but that shouldn't be hard to add in the end if I need to. I just did this: $query = mysql_query("SELECT p.regid, IF(above.et IS NOT NULL, above.et, below.et) FROM participants AS p LEFT JOIN (SELECT regid, MIN(et) AS et WHERE et >= 4.7 GROUP BY regid) AS above USING (regid) LEFT JOIN (SELECT regid, MAX(et) AS et WHERE et < 4.7 GROUP BY regid) AS below USING (participant_id)") or DIE(mysql_error()); while($row=mysql_fetch_array($query)){ echo "$row[et]"; } just to see what I get, this query is going to have to be more specific as in class and event id, but with just this I got an error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE et >= 4.7 GROUP BY regid) AS above USING (regid) LEFT JOIN (SELECT regid' at line 6
  16. I changed this line: if ($qp == 1){ $arr1[1] = "$firstname $row[lastname]"; $arrid1[1] = "$row[id]"; $r1[1] = "$row[r1]"; $r1s[1] = "$row[r1s]"; $r1rt[1] = "$row[r1rt]"; } to this: if ($qp == 1){ if (($row[q1] != '99.999') OR ($row[q2] != '99.999') OR ($row[q3] != '99.999')) { mysql_query ("UPDATE participants SET qpts = '16' WHERE id = $row[id]") } $arr1[1] = "$firstname $row[lastname]"; $arrid1[1] = "$row[id]"; $r1[1] = "$row[r1]"; $r1s[1] = "$row[r1s]"; $r1rt[1] = "$row[r1rt]"; } and now I get this error: Parse error: syntax error, unexpected T_VARIABLE in /home/orsca/public_html/pairings.php on line 227 edit: I noticed I had a space between mysql_query and (, removed the space and now I get: Parse error: syntax error, unexpected '}' in /home/orsca/public_html/pairings.php on line 227
  17. Which is what I have already, I just have the information stored on 1 row instead of multiple. So instead of making a new table like you said, just change the method to 1 row per round per user? id | eventid | userid | round# | rt | et | speed have a unique id, event id, user id, round number, reaction time, et, and speed for each row. What does above. and below. refer to?
  18. Could you explain this? It looks like you're calling to 2 new tables, but said to add 1 and show 1 at the top. I think I can work with something like this as a workaround if I understand it a little more. Thanks
  19. What you just posted really got me confused. Advanced queries do that. If I go any sort of route that requires me changing the DB, then I'm also looking at having to change a lot of code for stuff that already exists. I could MAYBE do the 3 tables just for qualifying and just for the classes that require this special query, and leave the rest alone. *shrugs*
  20. I was quite sure that over 24 hours would be plenty of time, what would the time frame be?
  21. Nothing in the source, just blank. I know everyone keeps mentioning the falsestart bit but that was actually taken out completely. I've switched hosts and everything is working fine now, I've added in to it quite a bit as well. I think it was a hardware issue.
  22. $query = mysql_query("SELECT * FROM participants INNER JOIN registrations ON registrations.id = regid WHERE class = '$_GET[class]' && eventid = $_GET[event] && cr >= '1' ORDER BY qp") or DIE(mysql_error()); edit: nvm, would this be caused by $_GET[class] not being set? It wasn't set in this one case when I got the message, when I set it, it was gone.
  23. I would love to slim it down to something very simple like you said, but the way the pairings are set up I couldn't figure it out. I had asked the person having me to do this to explain to me how the pairings are generated and he didn't know either. For that reason I wouldn't know any way to do it if I don't know where each qualify position is suppose to fall along with the byes. So I had to hard code each one to fill it in correctly. Beyond that, there is no reason why making a completely valid change from one line to the next should cause the page to go white and no errors to be displayed anyway. Everything is okay code. If you uploaded a file that just had echo "hello"; in it and it worked and just added another line that said echo "hello2"; and it then white paged, you would be in the same situation.
×
×
  • 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.