| |
| |
| |
|
Page: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
Comments:
<0> but then i would have to do so many range <0> s <0> i.e. a-b, c-d, e-f <0> thats why i wanted to use the foreach thing <1> sharmaa: if that code is going to handle thousands of dogs, i <1> 'm inclined to believe that your code is going about it the wrong way <0> hm <0> maybe ur idea is good <0> with the select * from range a-b <0> the thing is i would have so many queries <1> yes, that is a problem <0> or <0> hm <0> i thought <0> how would i do it <0> for each letter
<1> why would you want to query like that anyway? is it to group the names? <0> yes <0> the user then clicks on a range <0> and then gets the info of all dogs for that specific range <1> oh <1> well, that's easier then. you'll need to learn about SQL's "group by" command and the count(*) function <0> why would i use those <1> then it can be done with just one query <1> you just need to find out if there are dogs within the ranges right? <0> select count(*) from dog where name = [a-b]; <0> not sure <1> not quite that <0> why i would use the count here <2> so a "text/html; charset=utf-8" should display utf8 strings correctly and send textarea input as utf8 right? <1> i'm somewhat rusty. "select count(*), substr([first letter]) from dogs group by substr([first letter])" <0> hm <1> you'll need to find the correct way to substring or test for the first character. the one i gave really won't work <0> another thing i thought <0> was just make the range bigger <0> i.e. <0> ranges1 = array("a-dA-D") <1> so the result is that it returns the number of records, grouped by the first letter. with that, you can further group the data in php <0> then have multiple queries <1> no <0> with that specific range <1> no need <0> hm <0> im not sure what you mean <1> just use the query above, and then group it in php <0> im not sure what you count(*) <0> does <0> can you pastebin what u mean <1> ... okay. but it'll take a while for me to construct it. brb <0> ait <0> cheers <3> !tell sharmaa about <3> !tell sharmaa about u <1> sharmaa: http://pastebin.com/571267 <0> ah ok let me check deadroot <4> is there a tool to turn seconds into years? <0> cheers mate <1> sharmaa: that would give you an array of the number of dogs, according to their first letter. so no matter how you want to group it later, you just need to extract the information from the array <1> MikeH: www.php.net/date ? <0> hm <0> why do u write 'a' => 0 <0> should i fill it up till 'z' => 0 <1> yeap <0> ok <0> let me fill it up <0> hi deadroot <0> you still here? <1> yeah <0> ok <0> cool <1> try not to use the <enter> too much <3> sharmaa: if you use 'u' once again, it'll mute you. <5> Stormchaser: Nice.. I like this channel suddenly. ;) <3> lol <3> nap time <1> sharmaa: oh i made a typo. the last line should read "print_r($array);" <0> aha
<0> hm <0> when i run it <0> wait ill pastebin the results <0> http://rafb.net/paste/results/7dyJPI77.html <0> check this deadroot :-S <1> well, the sql query failed. do a: echo mysql_error(); <1> and fix the error <1> sharmaa: think about the code anyway. it doesn't have to run successfully. the idea of that code is quite clear. <0> hm <0> what does undefined index: mean <0> $array[strtolower($row[0])] += $row[1]; <1> all it does is to retrieve the number of dogs, grouped by their first letter. you can then use that information to do whatever labeling you want: a-b, a-d, a-f, a-k or whatever. end of story <0> i see <0> how come when i print it <0> it has [a] => 0 <0> [b]=> 0 <0> cause i think there should be dogs with that letter <1> that means that something went wrong <0> yea wheni run it says undefined index <0> $array[strtolower($row[0])] += $row[1]; <1> ... you should try to understand and fix it yourself <1> it's not a particularly complex code <1> and you don't have to use mine anyway. you just need the idea <0> i dont understand the substring(name, 0,1) <0> what does that do atually <1> that should retrieve the first letter of the names <6> are checkbox values returned as an array in $_POST? <0> aha <0> i still dont see why it says undefined index <0> is it maybe illegal to do $row[0] <0> or the strtolower <0> maybe <0> any idea deadroot? <1> ... :-/ <1> why don't you start with finding out what is the value of $row[0] <7> use print_r to look at the $array <1> actually, i think var_dump would be better in this case <0> hm <0> i tried doing print_r($row[0]); <0> at the end of the while loop <0> but it didnt prnit anything to me <1> because it's wrong <1> it should be print_r($array); <0> it says [] => 80 <0> and all the other letters [a] => 0 <0> etc <1> then it probably is whitespace <0> i did it from [a] to [b] <0> i mean a to h <0> a white space <0> hm <0> not sure how to fix the stuff inside the while loop <1> i'm not going into this anymore. i've given you the general idea on how to solve your problem and i do have other things to do <0> $array[strtolower($row[0])] += $row[1]; <0> please i just want to see it working <1> then learn how to debug errors and warnings. var_dump is your friend in this <1> and debugging skills are very important in programming. if you can't debug on your own, you should look for a new job <0> its jsut that the $array[strtolower.] <0> is confusing me <0> i dont know what it should do <1> it's an array manipulation thing <1> can somebody else guide sharmaa in this? <7> sharmaa, read the error, it tells you whats wrong <0> Undefined index: <0> i dont know where to define it <7> its the index of the array value <0> yes the thing is <0> it says 0 <7> ok so its 0 <0> i dont know what value instead of 0
Return to
#php or Go to some related
logs:
Fedora unexpected EOF while looking for matching ``' RudiRendeer lirc asus tv fm 7133 remote -D SSL_DEFAULT_VHOST #gentoo #debian #linux slime style-warning #php #linuxhelp
|
|