Jump to content

Humpty

Members
  • Posts

    132
  • Joined

  • Last visited

    Never

Everything posted by Humpty

  1. Got it. it was all in the SELECT DISTINCT on (field name), field, field etc... select distinct on (t1.fixtureid) t1.fixtureid, t1.teamid, t1.score, t2.teamid, t2.score from results t1 join results t2 on t2.fixtureid = t1.fixtureid where t2.teamid != t1.teamid;
  2. G'day Guys, As part of an assignment i need to display every 2nd record in the SQL. I am lost and need a point in the right direction. From a slight programming background I am thinking somehting like: SELECT * FROM table STEP 1
  3. I still believe I am understanding the point. (perhaps not) Previous suggestion still makes sense to me. if you really want to store as an array you probably can. But an array with 5000 entries in it makes less sense to me than using a database. a BLOB field (MySQL) may hold an array as it is. UPDATE tablename SET BlobFieldName = $ArrayName I've never attempted it as such, when I need multi things in one field I like to use "~value1~value2~Value3~" and so on The only issue I see with storing the array in a table is that to parse the array you probably have to pull it from the table. If you think I am not understanding then by all means ask me not to respond again or explain it again with different wording. (I am happy either way, just trying to help, sometimes keeping out is the best help I could provide )
  4. Why don't you just store the users ID (I'm guessing that below code is uniqie per user) <user> <id>182791273</id> ...and store then statusid you last got. If the status id is different on any occasion then the status has changed. ...then do whatever it is you are doing ....and then also update the status id. 5000 records shouldn't hurt anything I wouldn't think.
  5. I'm a little unsure what dc:date is exactly but perhaps this will help you: $MyTime = mktime(hour, minute, second, month, day ,Year); $MyNewTime = date("d-m-Y H:i:s", $MyTime); The mktime is 24 hours, and you can do maths in it too ! You can search web for help on both those functions, they are in the manual and I think they make pretty good sense. If you have to you may need to split your orignal date format up as a series of strings first. As I said I am not familiar with it and the -07:00 threw me off.
  6. Although some might find it a little odd couldn't you just use a hidden field as a flag on the page. When data submitted check the field value, in turn that will let your scripts know which page (1 or 2) needs showing?
  7. sorry it took so long to reply. fgetcsv was the answer. I had no issues with it based on the examples provided. I had to do some funky coding with array_flip for the header rows so that I could get the index # for the items i needed as a 'key' if you will. I also found complatibility issues is the CSV was saved via MS Office for Mac. I'm sure there would be ways around it but in this scenario there is no need for that. The code is a little lengthy so I won't paste it in here, however if someone needs some help with the array_flip method that I used then by all means contact me via a PM to notify me of your post and I will get back to you in your post. THANKS FOR THE HELP AND GUIDANCE guys !
  8. looked shorter than what I was doing. Will check it out, thanks.
  9. G'day Stig1, I'm a noob, and if a pro can provide a different answer the listen to them. It's my belief that you can't do it like that. Classes and Functions don't carry variables and stuff from elsewhere. e.g. Variable of $DatabaseName = "Frog"; doesn't carry through to classes or functions automatically and you have to create it again. As such you can have the same variable name $DatabaseName in your code and your function and each in turn can hold a different value I also believe that once the function is ended that value disapears and has to be recreated/reassigned next time you run that function. There are 'Global' or similar types of variables that can be used I believe (possibly only in classes). I have had an issue within classes as well (you can set a function in a class with the same name as that class and any time you call to that class that function runs first) ... I did set Database connections in there but they still didn't carry through to the function I was calling. I hope this helps, if need be ask another Q of what I said I know I talk lots and may have confused / babled. If nothing else perhaps someone else will jump in telling you how wrong I am and also providing you with a correct answer just for the sake of showing me up / correcting me
  10. G'day Again all, I have firstly googled and searched this forum, but no resolution found. Trying to do: 1) Upload CSV (done) 2) Parse CSV 3) Set an Array Where the Keys are the values of the CSV header row 4) Assign the values of the following rows to a variable. 5) Update an MySQL Database ($SplitImportString[x] is the line I am dealing with from the CSV file...parsing it one line at a time) Example 1 (CSV): Col_1,Col_2,Col_3 Val_A1,Val_A2,Val_A3 Val_B1, Val_B2, Val_B4 Example 2 (HeaderArray) : $SplitHeaderRow = split(",", $SplitImportString); (this works fine) Now I want to create an array that uses those as keys. Below is an example of what I want in the array Example 3 (RowArray) : (Key = Value) Col_1 = Val_A1 Col_2 = Val_A2 Col_3 = Val_A3 I'm just not really sure what I need to do to make the KEYS of RowArray be the Values of HeaderArray. In the end i am will be performing the following SQL: "UPDATE `table` SET `" . $HeaderArray[0] . "` = '" . $RowArray[$HeaderArray[0]] . "',`" . $HeaderArray[1] . "` = '" . $RowArray[$HeaderArray[1]] . "' WHERE `" . $HeaderArray[0] . "` = '" . $RowArray[$HeaderArray(0)] . "' LIMIT 1" and again using the predifined values above "UPDATE `table` SET `Col_1` = 'Val_A1',`Col_2` = 'Val_A2' WHERE `Col_3` = 'Val_A3' LIMIT 1" I hope at the very least you can understand what I am trying to do and point in a better / different direction. Using in PHP 4.x I don't like using plugins and functions from online, nor 'toolboxes' as I don't like the idea that the development of them may stop. I am happy to use predifned php or MySQL functions, statements etc. Thanks for your help, let me know if you need further explanations. UPDATE: Sorry; The whole purpose is that the user will upload a CSV and as long as it has Headers I know what fields the user wants updated and each line will in turn store the values. The user has a need for MANY different updates via CSV and this seemed far easier / better / flexible than hard-coding for each need and then having to do it again if they find a new CSV 'layout' / 'order' for some other update.
  11. I could misunderstand what you are saying, if so post again and rephrase (My brain is broken today, but isn't a full piece any day anyway) <label>Gender </label> <select name="gender<?php echo (int)$i+1;?>" id="gender<?php echo (int)$i+1;?>"> <option value="gender<?php echo (int)$i+1;?>" selected>gender<?php echo (int)$i+1;?></option> <option value="Male">Male</option> <option value="Female">Female</option> </select><br /> Although I i'm not fully understanding it appears to me that on your form you will have for example 3 of these each named: gender1 gender2 gender3 but instead of statically enterig the numbers you are using code. So the above should work ok. If that doesn't work try this: replace: <option value="gender<?php echo (int)$i+1;?>" selected>gender<?php echo (int)$i+1;?></option> with this: <option value="gender<?php echo $_REQUEST["gender"(int)$i+1];?>" selected>gender<?php echo $_REQUEST["gender"(int)$i+1];?></option> if that fails let me know, I know I have code around in a few places where I have done that or similar. ...on another hand if you are familiar with them you could load them into an array etc...but if you are not familiar with that concept just ignore this comment
  12. Indeed it was. I don't understand why though. It all revolves around an include. I have put the info below as to what I did and a tad more clarification on the code (ommitted because I didn't think it would matter.) It would still be nice to know why this happened but none-the-less I have rectified it and will look at includes next time. Firstly thanks heaps to all those who helped: premiso Humpty sasa redarrow corbin I appreciate it. This is what was happening (including the includes) (start file 1) START Loop1 include file2 (start file 2) START Loop 2 include file 3 (start file 3) if (condition){ continue; (this is where the error occured) } (end file 3) END Loop 2 (end file 2) END Loop1 (end file 1) The only change I made was to take the code in file 3 and put it inside file 2 (instead of the include command (which by the way was working, else we wouldn't have even reached that point of code where things errored). This is what I ended up with (start file 1) START Loop1 include file2 (start file 2) START Loop 2 // this is where we USED TO include file 3 // this used to be start of file 3 if (condition){ continue; (this is where the error occured) } // this used to be end of file 3 END Loop 2 (end file 2) END Loop1 (end file 1) I really hope that this example can help someone else if need be, and I hope that anyone reading it can understand what is happening, which is why I didn't use code other than the if...then, so that people can see this issue out of context perhaps helping them put it into context for themselves. I am also leaving this open for a little while to give the opportunity for someone to mention how / why this would have happened and been fixed....it will help me (and or you) prevent this in the future. I will mark as solved shortly. THANKS HEAPS
  13. G'day jdhorn, By the sounds of what you are saying is that as the page refreshes back to itself you are loosing the selection in the options. Perhaps the following will help and the use of "selected" in your option tag. (this will also work when you use the value item inside the option tag (if you are using it). <?php $usrStatus=$_POST["usrStatus"]; ?> <select name="usrStatus" class="ezButtonsINPUTBOXplain" id="usrStatus"> <option selected><? echo "$usrStatus" ?></option> <option>ACTIVE</option> <option>SUSPENDED</option> <option>CLOSED</option> </select> if that doesn't help msg back, I may not understand your question and this was a basic thing (but my brain is a basic thing so i may not be able to help)
  14. Yeah those 2 variables are set in the real code, I just use those 2 A and B to indicate that they were not a match for purposes of showing cut down code so what else could cause it to produce this error? please keep in mind that in orginial code i had continue; but have tried break, continue 0, continue 1, and continue 2.....all of which not worked.
  15. yeah only becuase I can't work it out I was going to mention in the original post that I have tried using break; continue 0; continue 1; continue 2; ...all instead of continue; but the same issue. What I do not understand is the concept of 'level'. If it refers to the looping structures (loop inside loop) or the itteration of the current loop. Could you please shed some light on that so as I can understand what is happening / causing the error. The other thought is that I am makeing $ezAPCSCCounter = $ezAPCSCDRCount. but as such I would expect it to goto the begining of the loop and then decide that there is no need to loop again.
  16. G'day Guys, I am sure that the it is my lack of knowledge that got me and not understanding fully loops. My issue is getting a "Fatal error: Cannot break/continue 0 levels in..." message inside of a loop. The conintue; command happens inside of an IF THEN trying to continue a WHILE, however that WHILE is inside another WHILE...I believe this is where my problem may be. Below is a sample of what I am doing with LOTS of code stripped out so you can see the basics. $ezPhoneRun = 0; $ezPhoneCount = 100; // this value varies. while ($ezPhoneRun < $ezPhoneCount) { $ezAPCSCCounter = 0; $ezAPCSCDRCount = 1; //I have just added this here for your sake, the real value is a varied. while ($ezAPCSCCounter < $ezAPCSCDRCount) { if ($AAA != $BBB){ // do some code stuffs, loop $ezAPCSCCounter++; continue 0; } $ezAPCSCCounter++; } // END while ($ezAPCSCCounter < $ezAPCSCDRCount) { $ezPhoneRun++; } // end loop for isp's phone table loop I have placed in some obvious things just so that you know that they are happening, $AAA and $BBB aren't important, but that is to point out that I am entering that IF THEN when the problem occurs. Thanks in advance
  17. [update: I had to upload it for someone else to view, so it's online now here: http://www.lodi.com.au/ppearl/ ] G'day Guys, Sorry I couldn't be more specific in the subject, I also haven't search the boards as I have no idea what the problem is to search for in words. Below is the CSS that I am using, and a breif mock, up of the HTML that is in place and using it. What is happening is that I have an image at the bottom right of my page, which i have set as attchment fixed, (unsure if that is correct thing to do but it worked). however I am finding that it is being somehow carried through on / in another table. It looks good as one or the other but when it appears on both it sucks and looks ugly. I can get it online for you to view if required withing a few minutes of being requested. CSS: .MainTable{ background-image: url(../newimg/backing_top_left.jpg); background-repeat: no-repeat; background-position: left top; } .TableHeader{ margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 80%; color: #666666; background-image: url(../newimg/backing_header_backing.jpg); background-repeat: repeat-x; background-position: left top; filter:alpha(opacity=90); filter: progid:DXImageTransform.Microsoft.Alpha(opacity=90); -moz-opacity: 0.90; opacity:0.90; border:0px none; z-index: 1; } .RealTable{ font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: x-small; color: #000000; margin: 0px; width: 750px; background-color: #FFFFFF; border: 2px solid #000000; filter:alpha(opacity=60); filter: progid:DXImageTransform.Microsoft.Alpha(opacity=60); -moz-opacity: 0.60; opacity:0.60; z-index: 1; } html, body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; font-family: Tahoma, Arial, Helvetica, sans-serif; font-size: 80%; color: #666666; background-image: url(../newimg/backing_bottom_right.jpg); background-repeat: no-repeat; background-position: right bottom; background-color: #D8D6DB; background-attachment: fixed; } Mock up of html: (the html at this stage was small enough so i have actually copied and pasted instead of a mock up <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <link rel="stylesheet" type="text/css" media="screen" href="css/styles.css" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <table width="100%" border="0" cellpadding="0" cellspacing="0" class="MainTable" > <tr> <td colspan="3"> <table width="100%" height="103" border="0" cellpadding="0" cellspacing="0" class="TableHeader"> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table></td> </tr> <tr> <td> </td> <td align="center"> </td> <td align="center"> </td> </tr> <tr> <td> </td> <td align="center"><table width="200" border="0" cellpadding="0" cellspacing="0" class="RealTable"> <tr> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> </tr> </table></td> <td align="center"><p> </p> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table> </body> </html> any help would be great even if it is a push in the right direction.
  18. That was exactly the point, I wasn't in a function to start with. That does seem like the best way to go though. A function with no variables will just as well as a function with variables, and on the same side of the fence there is no need to return any values etc, just use return to exit that function. That is what I was looking for, seems like it would be the best and closest thing to a sub. Thanks dudes. (will leave topic unsolved for a bit in case someone comes up with somethign else)
  19. I'm not using a function, however does seem like a good avenue to follow for what I want. (basically want the equivelent of calling a sub and exiting that sub without exiting the program)
  20. G'day Guys, Here is a Query from a quer bloke: (Visualising VB code structure in my head as I type this) I want to create a code block, Sub, Function whatever you want to call it. I want to exit that block but still permit the PHP script to run. (Example Ideal World: Use a whole bunch of Includes with the ability to use exit(); without stopping the main script.) I'm after either a push in the right direction or a recomendation on a way to do this. At this stage all I can think of is to use continue; and place all my code in a loop which loops once. If this post is a little too Dr. Seuss please let me know and I will try to reword it. Thanks - humpty
  21. Sorry for delay in response, I have no idea why I thought it, I just didn't think it mattered. As a human looking at it I would rather read it as directory 18692, don't know why either, just appeals to me more.
  22. or this link even, it works: http://www.setbb.com/phpbb/?mforum=sudoku
×
×
  • 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.