Jump to content

janroald

Members
  • Posts

    78
  • Joined

  • Last visited

    Never

Everything posted by janroald

  1. You can check for a thumbnail version of the image, "..._thumb.jpg" or whatever you call your thumbnails, or else create a thumbnail using typically imagemagick/convert on most linux servers or maybe gd library in windows(usually not a default package). http://no2.php.net/manual/en/function.getimagesize.php This function in php can help you to decide what ratio etc. u should use when displaying the pictures, and lots of other helpfull stuff. Now get on reading :-)
  2. Hehe, you replied before i modified my post, and obviously the added info wasn't needed :-) The "left-align" thingy with heredoc is really annoying. Breaks indentation style. i wish for a perl-like qw structure in php :-)
  3. Yep, that code snippet should work fine, as Doqrs says. Maybe you have some indentation in your real code that makes it fail, like : if(smthing) { $contents = <<<EOF header("location: somewhere"); EOF; } In this case, you will get an error, because you cant have spaces or tabs or anything other than "EOF;" on the EOF line. If it's your fopen/fwrite that fails you should check file/folder permissions. http://no2.php.net/manual/en/function.fopen.php http://no2.php.net/manual/en/function.fwrite.php
  4. Sorry crayon, my reply was unclear and might lead to this misunderstanding. Yes, I can think of several ways it can be helpful, a "hellofalot" actually. In most cases i would too say that this is a better solution than just using []. I Just ment to say that in the context of this thread, the order of the array was not interesting. I had actually tested numbered indexing [\d] 30 seconds after i read about [] in this thread :-) In a database-listing context, the possibility of using row id's as array indexes for the checkbox array creates lots of opportunities. A checkbox object now has posting now has 3 interesting variables; name, value, unchecked. I see new possibilites in both posting and js event handling. Anyways, I do appreachiate you trying to give me some good advice :-)
  5. Well, thats evidently :-) But when you supply the value for the checkbox like in the example above, you got all that you need. The array order is not interesting, only the values inside it.
  6. I've worked with html for > 10 years, and this taught me something new :-) I've named other form elements with array notation before (select multiples etc.), but until now I've created serialized strings of dynamically created checkbox names and sent the string data with a hidden box :-) Imagined that I tried this a long time ago and found that it wasn't possible with checkboxes, but obviously I either tried it a bit too early, or i did something wrong :-) Just shows why programming/markup is so fun; you learn something new every day, even when you don't expect it :-)
  7. [quote author=shoz link=topic=124880.msg518914#msg518914 date=1170336687] [quote author=janroald link=topic=124880.msg518816#msg518816 date=1170323967] [quote=fenway]Also, having it the where clause will also "solve" your problem in code, since the records will be discarded[/quote] Are you saying this query would be better solved with a where clause? [/quote] If you don't want a result that contains "a.bref"s with a -1 then you should move the test to the WHERE clause. [/quote] I still want a result with values from table a, even though the relation with table b isnt found. a.brefs with a value of '-1' is constructed to tell me that there is no relation,or the relation commits to every row in table b. To my limited experience, I havent found a way to do this with a WHERE clause.
  8. hehe, I chose to look away from that one, even though it was very tempting :-) Guess I'm just a bigger man ;-)
  9. You are doing most things wrong here m8, and really need to read up on the basics some more. I'll help you get a bit further, but ^ First of all: what are you trying to do here? Are you just trying to count the records? They you could do : $sql ='select count(id) as number_of records from admin'; $result = mysql_fetch_array(mysql_query($sql)); echo $result[0]; // this will now print number of records total in your table You can also do $result = mysql_fetch_assoc(mysql_query($sql)); echo $result[number_of_records]; // this will now print number of records total in your table Or you can do $result = mysql_fetch_object(mysql_query($sql)); echo $result->number_of_records; // this will now print number of records total in your table Say you want to print everything in your table : $sql ='select * from admin'; $result = mysql_query($sql); $number_of_rows = mysql_num_rows($result); echo 'Number of rows total : '.$number_of_rows.'<br>'; while($row = mysql_fetch_assoc($result)) { echo 'id='.$row[id].'<br>'; echo 'name='.$row[name].'<br>'; //if there is a coloumn named 'name' etc. } Good luck :-)
  10. So no use for the short-circuit then, i see. EXPLAIN +----------------+--------+---------------+---------+---------+---------------------+------+-------+ | table          | type  | possible_keys | key        | key_len | ref                          | rows | Extra | +----------------+--------+---------------+---------+---------+---------------------+------+-------+ | a              | ALL  | NULL              | NULL    |  NULL    | NULL                      |    7 |      | | b              | eq_ref| PRIMARY        | PRIMARY |4        | ak.kontaktpersonref |    6 |      | +----------------+--------+---------------+---------+---------+---------------------+------+-------+ [quote=fenway]Also, having it the where clause will also "solve" your problem in code, since the records will be discarded[/quote] Are you saying this query would be better solved with a where clause? I'm also planning to use several "join on" clauses with a couple of other tables and primary key sorting and limit...
  11. This is getting quite interesting :-) I'll get back to you both tomorrow with EXPLAINs etc. :-)
  12. [quote=shoz]I don't know if I've followed everything you've posted but note that you should use the query that effigy posted originally.[/quote] That was what i too discovered in my last post. [quote=shoz]EDIT: To be clear, even if all of the a.bref's are -1 it's more likely to be slower.[/quote] If mysql uses "short-circuit" comparison ( havent found docu, but prob. yes ), I dont see how this statement can be correct. The test "a.bref <> '-1'" must be a quicker test than "a.bref = b.id" since the latter needs to lookup another table. Hence; if most a.bref's are '-1', only first test will be evaluated and you would have effectively replaced a "heavy" test with a "light" test.
  13. And i assume you get output 'Hello world' to screen if you remove you connect line?
  14. Fenway : Well, the typical use for theese queries are to get a row from a table, with the references "translated". Example for the kids: table with invoice's and in that table references to customer id's. You want the invoice information and the full name of the customer without making two queries. Normally, an invoice always has a valid customer id, and hence this ON-clause would not be needed - unless someone has deleted the customer record (dr.evil) :-) The reason i need this ON clause, is because i [b]know[/b] that in some cases, i [b]will[/b] look for an b.id, that isn't there. Say table a is a holding crm-lead information, table b is customers. When inserting a lead row, the user can either choose to say "this lead is about _that_ customer" or "this lead is about ALL customers" or this lead is currently not about any customer, but could be". For case 1 we put in the customer id as a reference. In case 2 we put in that the customer id is "0", and in case 3 we say "-1". Now "0" and "-1" does of course not exist in table b, because then we would have to put in two default rows in table b every time we duplicate the database, and it would be a drag when doing listings etc. unless we filter them out. With such an ON clause in the query, this gets solved in the code. There are probably smarter ways to do this query though, but I don't know them... Now I see what you mean about it might beeing slower, and I think you are right.  ---------test1------------test2-------- ON (a.bref <> '-1' and a.bref = b.id) say 10% of the  a.bref's are '-1', then in 9 out of 10 cases you will have 2 tests instead of just one, and just one time, it "short-circuits" and avoids the potentially slower test2. Test 1 then has to be 10?(no time for math now :-) ) times faster than test2 for the short-circuit to be efficient.
  15. With only that line of code, you won't output anything to the screen, just connect. Just trying to rule out the obvious before i try to help you :-)
  16. That works great, thanks! Modified it a bit so that the comparison between a and b isnt neccesseary if a.bref <> '-1' I guess this will make it quicker since the ON clause will "short-circuit" on first test and table b wont be checked if a.bref = '-1' select a.id, a.this, a.that, a.bref, b.something from a LEFT JOIN b ON (a.bref <> '-1' and a.bref = b.id) Wouldn't you agree?
  17. Typical query : 'select a.id, a.this, a.that, a.bref, b.something from a,b where a.bref = b.id'; Problem is that if the relation between a and b isn't found the query returns nothing. If i know that i'm quering with a.bref value of '-1', and that the corresponding b.id doesn't exist, how can i alter my query to check if a.bref = '-1' and in that case return me a row where "something" contains ex. 'not found' ? Essentially I just want to get the values from table a even if the relations with b doesn't exist. Any clues would be greatly apprechiated. 
  18. Found the problem. When dragging the pictures, firefox makes its own relative src for the image. Because of including etc, my base href will throw my images into nothingness.
  19. I see you have found the right way to do it. Great work. I see there was a flaw in my logic also, but since you have the solution I wont bother with the details as of why your logic failed. It was probably a string/integer comparison problem or something other absurd js-typical hassle. The way you do it now is the correct way.
  20. Your date comparison is all wrong. Say enddate is 2007/06/07 and startdate is 2006/05/06, then your comparison would be if(2006 <= 2007 && 06 <= 05 && 07 <= 06) {                                 ^                ^ Both month and day will return a false even though your date is in the future. I dont have time to show you how to do this right now, but googling some "javascript date comparison" or similar should get you started.
  21. I've got an iframe going into designmode at onload. Everything looks good, images and formatting is like it should be. However, when i try to drag/drop the images around in the text, they dissapear. This only happens in firefox, not in IE. Any suggestions why this happens? I would also like to get the position of the img tag in the text if that is possible, but as of now the above is my priority problem.
  22. [!--quoteo(post=345613:date=Feb 14 2006, 12:23 PM:name=Javizy)--][div class=\'quotetop\']QUOTE(Javizy @ Feb 14 2006, 12:23 PM) [snapback]345613[/snapback][/div][div class=\'quotemain\'][!--quotec--] Taken from [a href=\"http://www.mozilla.org/access/keyboard/tabindex\" target=\"_blank\"]mozilla site[/a] So if you're already setting a function for the onfocus event for the textareas, add a function call that stores the id in a variable, and then use this in a getElementById in your insert function. [/quote] Nice. Why didn't I think of that... Easy and good solution! Thx man.
  23. I want to insert text into a currently focused/active textarea without referring to id or looping through the elements. Simply insert into the textarea that currently has the "text-blinker" in it. Anyone?
×
×
  • 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.