Jump to content

Barand

Moderators
  • Posts

    24,566
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. The only loop I can see in the code is foreach($rows3 as $row){ Where is $rows3 defined?
  2. html <img src='green-up-arrow.png' alt='normal'> <img src='im_rotate.php?fn=green-up-arrow.png' alt='rotated'> im_rotate.php <?php $fn = $_GET['fn']; $im = imagecreatefrompng($fn); $bg = imagecolorat($im, 0,0); $rot = imagerotate($im, 90, $bg); header("Content-type: image/png"); imagepng($rot); imagedestroy($im); imagedestroy($rot); ?> output
  3. Looking at that code one would think you had never heard of JOINS. However, I know differently. http://forums.phpfreaks.com/topic/296174-trying-to-get-a-several-rows-and-colums-with-data/?do=findComment&comment=1511474 Not open to advice are you?
  4. To use array_merge you need to decode the data as an array. Set second parameter of json_decode() to true $data = json_decode(file_get_contents($playlist), 1);
  5. Given your array looks like this: $data = Array ( 0 => Array ( 'text' => '96.1 km', 'value' => 96113 ), 1 => Array ( 'text' => '52.1 km', 'value' => 52096 ), 2 => Array ( 'text' => '102 km', 'value' => 102064 ), 3 => Array ( 'text' => '30.0 km', 'value' => 29992 ), 4 => Array ( 'text' => '43.9 km', 'value' => 43864 ), ); then using ksort() will merely sort on the keys I highlighted in red. You will need a custom sort, using usort() to sort on the text values $data = Array ( 0 => Array ( 'text' => '96.1 km', 'value' => 96113 ), 1 => Array ( 'text' => '52.1 km', 'value' => 52096 ), 2 => Array ( 'text' => '102 km', 'value' => 102064 ), 3 => Array ( 'text' => '30.0 km', 'value' => 29992 ), 4 => Array ( 'text' => '43.9 km', 'value' => 43864 ), ); usort($data, function($a, $b) { return strnatcmp($a['text'], $b['text']); }); echo '<pre>',print_r($data, true),'</pre>'; which gives Array ( [0] => Array ( [text] => 30.0 km [value] => 29992 ) [1] => Array ( [text] => 43.9 km [value] => 43864 ) [2] => Array ( [text] => 52.1 km [value] => 52096 ) [3] => Array ( [text] => 96.1 km [value] => 96113 ) [4] => Array ( [text] => 102 km [value] => 102064 ) ) Alternatively, you can sort on the "value" values using usort($data, function($a, $b) { return $a['value'] - $b['value']); });
  6. Is this what you're wanting? class february { private $year; public function __construct($year) { $this->year = $year; } public function numDays() { $d = new DateTime("{$this->year}-02-01"); return $d->format('t'); } } $f = new february(1900); echo $f->numdays(); // 28 $f = new february(2000); echo $f->numdays(); // 29
  7. Use PHP GD library and http://php.net/manual/en/function.imagerotate.php
  8. Alternatively $images = array ( 1 => 'smile.png', 2 => 'laughing.png', 3 => 'blush.png', 4 => 'smiley.png' ); $people = array ( ':)' => 1, ':laughing:' => 2, ':blush:' => 3, ':d' => 4, ':D' => 4 ); But the question is "why are you imposing an artificial constraint that makes life difficult for you when this: $people = array ( ':d' => 'smiley.png', ':D' => 'smiley.png' ); is a perfectly legitimate array?"
  9. getImageSize() returns an array. eg list($width, $height, $type, $attr) = getimagesize("img/flag.jpg"); and you should be checking the uploaded tmp file.
  10. http://it2.php.net/manual/en/features.file-upload.multiple.php
  11. As you have already been told, you would need to store the user table's id in the profile so the correct profile record can be associated with its user +----------+ +----------------+ | user | | user_profile | +----------+ +----------------+ | id |---+ | userProfileId | | name | | | username | | email | | | picName | | username | | | picPath | | password | | | name | +----------+ | | introduction | | | specialization | | | skillset | | | email | | | contactNo | +---| user_id | +----------------+
  12. I have done in the past but I am in the middle of creating a small application to automate the process
  13. +--------------+ +-----------+ +----------------+ +-------------+ | contact_info | | register | | health_profile | | bloodgroup | +--------------+ +-----------+ +----------------+ +-------------+ | username |---+ | id (PK) | | id (PK) | | id (PK) | | phone | | | firstname | +-------| username | +-------| user_group | | address | | | lastname | | | blood_group |-------+-------| donor_group | | town | | | email | | | age | +-------------+ +--------------+ +----<| username |----+ | weight | | password | +----------------+ +-----------+ then SELECT user.firstname as user_firstname , user.lastname as user_lastname , bg.user_group , donor.firstname as donor_firstname , donor.lastname as donor_lastname , bg.donor_group , ci.phone , ci.address , ci.town FROM health_profile as hpu INNER JOIN register as user ON hpu.username = user.username INNER JOIN bloodgroup as bg ON hpu.blood_group = bg.user_group INNER JOIN health_profile as hpd ON bg.donor_group = hpd.blood_group INNER JOIN register as donor ON hpd.username = donor.username INNER JOIN contact_info as ci ON donor.username = ci.username WHERE hpu.username = '$patient' AND hpu.username <> hpd.username ORDER BY donor_group Job done
  14. You need that to query for possible donors
  15. Looks like you need another table to store bloodGroup | compatibleGroup -----------+---------------- O- | O- O+ | O+ O+ | O- A- | A- A- | O- A+ | A+ A+ | A- A+ | O+ A+ | O- etc
  16. You can't just change the word SELECT to UPDATE and magically get a valid UPDATE statement. http://dev.mysql.com/doc/refman/5.6/en/update.html
  17. Do not run queries in loops. Create a single query using a JOIN. SELECT p.nome , COUNT(c.produto) as contagem FROM produtos p LEFT JOIN carrinho c ON c.produto = p.nome GROUP BY nome ORDER BY contagem DESC Loop through the results echoing "nome" and "contagem"
  18. Will that use the indexes?
  19. Just my 0.02 worth, but if you store a date of 9999-12-31 instead of NULL in the end date of the current price then it makes joins easier when you want the price that was applicable at the time of the transaction EG SELECT .... FROM transaction INNER JOIN price ON transaction.date BETWEEN price.startdate AND price.enddate
  20. Yes, GROUP_CONCAT is one way. The other way is the same as in your other thread for the emails.
  21. That's the way joins work. They match data in one table with the corresponding data in the other, matching on the key values. If you have 1 record in tableA matching 3 records in tableB then you get 3 records output, each with the data from B and the matching data from A.
  22. You may find it easier to concatenate the image names into a comma-separated string for each service $prep_stmt = " SELECT s.id , s.name , s.description , i.image , GROUP_CONCAT(i.image_path) as images FROM services s LEFT JOIN images i ON i.service_id = s.id GROUP BY s.id";
  23. Not so long ago I spent hours answering these same questions for you in this topic http://forums.phpfreaks.com/topic/296918-automatic-php-email/ That topic shows you how to join to the renewal table. Now you want us go through it all again? Where were you during that marathon topic. If you cannot be bothered to learn you are wasting our time.
  24. It should be the id of whichever user you want to link that particular visitor record. So, if that is what is in $_POST['userid'], then yes $userid= mysqli_real_escape_string($conn, $_POST['userid']);
  25. The only value you ever store in $userid is an empty string
×
×
  • 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.