Jump to content

Humpty

Members
  • Posts

    132
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Humpty's Achievements

Member

Member (2/5)

0

Reputation

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