Jump to content

Alex

Staff Alumni
  • Posts

    2,467
  • Joined

  • Last visited

Everything posted by Alex

  1. Okay.
  2. Well, first off you'd need to use the comparison operator, == (not =). Unfortunately you can't do exactly what you're proposing in PHP, you would have to do: if($var == 'something' || $var == 'something else' || ..) If you have a lot of possible values, alternatively, you could put them in an array and use in_array: $possible_values = array('something', 'something else', 'something else else'); if(in_array($var, $possible_values)) { // ... }
  3. Nowhere in that code are you outputting anything. You're either not showing enough code, or simply aren't ever outputting anything.
  4. Well, your real problem is that your database is structured poorly, so it's making a task like this not so easy to accomplish. Anytime you're storing concatenated data in a field like that is a pretty good indication of poor database design. If you remove the "Done" field from the Tasks table so that it's just a table to describe each task, then you can create another table of completed tasks. In this table you could have the id of a user, and the id of the task completed. So a record for each task each user has completed. Then selecting the tasks that haven't been completed for a particular user is a simple, and much more efficient, task.
  5. The selector should be img.online not #img.online.
  6. First you'll need to create the image resource for the image you want to merge onto your existing GD image: $pic1="2011-Chysler-Town-And-Country-pic1.jpg"; $pic = imagecreatefromjpeg($pic1); Now you can merge your two resources: $im and $pic using imagecopymerge: imagecopymerge($im, $pic, 0, 0, 0, 0, 640, 480, 50); Look at the manual to see what the parameters mean to get exactly what you're after.
  7. You're planning on using AJAX, and that link explains AJAX. How could it not be relevant? You're after a quick solution, and specifically one that doesn't even make sense given the nature of AJAX. There is no simple "copy & paste this magical code and everything will work". It depends on your situation. If you want to get the data from a PHP function, then have the PHP page call the function.
  8. What's the error?
  9. imagecopymerge is what you're looking for.
  10. You obviously don't know how this technology works. I suggest you read into it before you attempt to use it. The mozilla link fugix posted is a good place to start.
  11. "Field" isn't a particularly esoteric term. I think your average person would understand that.
  12. I'm not entirely sure what you're asking, can you try reforming the question?
  13. Alex

    pdf help

    Instead of this: $name1 = $select = mysql_query("SELECT * FROM members") or die(mysql_error()); while ($member = mysql_fetch_array($select)) { ''.$member[name].''; } and this: $pdf=new PDF(); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('Times','',12); for($i=1;$i<=40;$i++) $pdf->Cell(0,10, $name ,0,1); $pdf->Output(); Which I'm not very sure what you're trying to accomplish with it.. You should loop through the database list and add them to the PDF at the same time, in a single loop. So something like this: $pdf=new PDF(); $pdf->AliasNbPages(); $pdf->AddPage(); $pdf->SetFont('Times','',12); $select = mysql_query("SELECT * FROM members") or die(mysql_error()); while($member = mysql_fetch_array($select)) { $pdf->Cell(0,10, $member['name'] ,0,1); } $pdf->Output();
  14. Alex

    pdf help

    In what way isn't it working? Assuming your PDF Output method is supposed to actually output the pdf to the browser, you shouldn't have any other output in your file, so no HTML.
  15. This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=331228.0
  16. I realized that you created another thread with the code, so I merged them. You already have the loop, so now just output a new table row for each loop. To record the frequencies of each result you can create an array with an index for each result (1-6) and initialize each element with a value of 0. Then simply increment that element every time it's rolled.
  17. Why don't you post what you have so far? If you just need help with the loops maybe the documentation and examples will suffice: for, while
  18. This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=322620.0
  19. The error is pretty self-explanatory. You can't call that method statically, you need to change an instance of the MySQLi object. $mysql = new MySQLi($CFG->dbhost, $CFG->dbuser, $CFG->dbpass, $CFG->dbname);
  20. Well I don't think it accomplishes the task you're after completely. The second parameter isn't even used.
  21. Your description of what you need to do doesn't seem complete, or consistent with your example. Why do you need to take a parameter "diameter"? Where should that parameter be used? A simple example of what it sounds like you want: function area_from_diameter($diameter, $str) { if($diameter < 0) { return -1; } return M_PI * pow($diameter / 2, 2); } $diameter = 5; echo area_from_diameter($diameter, "diameter");
  22. You have a few scope issues. Variables like $pi, $radius, etc.. that are defined outside of the function and aren't passed in won't be accessible in that context (You don't even need to define $pi yourself, you can use the predefined constant M_PI - it will be more accurate anyway). You've named things in a strange way that don't really make it clear as to what your intentions are; For example, "if($radius == "Diameter")", that doesn't really make sense, and I'm not sure what you're trying to accomplish with that. You also seem to have some problems with your formulas. For example, the area of a circle is: [imath]A = \pi r^2[/imath] (you can do exponents in PHP using the pow function).
  23. You have a few problems there. You can't set properties through "this.prototype", and you don't define properties with "var" just use the this keyword. This won't throw any errors, but I'm not entirely sure what you're attempting to do: function JEffect(){ this.props = new Array('x', 'y'); this.in_array = function(needle, haystack){ for(var k in haystack){ if(k == needle){ return true; } } return false; } } JEffect.prototype.transition = function(obj, prop, begin, finish, drration){ if(!this.in_array(prop, this.props)){ alert('not found'); } } var effect = new JEffect(); effect.transition('', 'm', 1, 2, 2); Because you're adding the in_array method in the constructor I'm guessing you want to add that to the JEffect prototype as well, but I left it as you had it.
  24. Well, you have a few issues there. For example, I'm not sure what you're trying to do here: $mean = (($array_total/$array_count) / $array_count); Shouldn't that be just $array_total / $array_count? Anyway, I'll attempt to explain how to go about solving this problem step by step.. Before we attempt to write a program to calculate standard deviation we must understand what standard deviation actually is, and often just writing down what you're trying to replicate in a program makes it much easier. Standard deviation is defined as: [tex]\sigma = \sqrt{\frac{\sum_{n = 1}^n (x - \overline{x})^2}{n}}[/tex] In words, this simple means that for each number we find the different between it and the average of the numbers, square that result, then find the average of all the results, and take the square root of that. So, now all we need to do is convert this into a procedure in code. First, we'll find the average of the set we're dealing with: $mean = array_sum($sample) / sizeof($sample); Now, we'll loop through all the values in array and find square of the difference between each number and the mean. $devs = array(); foreach($sample as $num) { $devs[] = pow($num - $mean, 2); } Now that we have an array ($devs) of the deviations, we simply find the average of those, then take the square root of that. So.. $standard_deviation = sqrt(array_sum($devs) / sizeof($devs));
  25. I don't think that's a fair comparison. In the 90s cars were already being mass produced for nearly a century with the rough idea being around for over 3 centuries, whereas the web was just getting off its feet in the 90s. Here's an example of what a car might have looked when it was the same age as the web was in the 90s: http://www.blurtit.com/var/question/q/q1/q17/q172/q1723/q172323_382419_860_car1 Granted all websites in the 90s weren't completely horrendous, but there has certainly been an increase in the look and feel of your average website over the years.
×
×
  • 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.