Jump to content

Barand

Moderators
  • Posts

    24,603
  • Joined

  • Last visited

  • Days Won

    830

Everything posted by Barand

  1. Some explanation of the whole process would help. For example, is that data the result of a single call to the url or accumulated from several calls. If several, how are you storing it? Do you want individual total for every second or is it that the data comes in every second but you want the accumulated totals for the day/hour or whatever time period? That is JSON data so you might want to start by looking at json_decode()
  2. How to accomplish what? If the code isn't working (whatever not working means) it only shows us what you don't want too do.
  3. The section of code you posted above selects the profile record matching the user record. If there is no matching profile then those fields are null in the results. So if the userprofileid is found, the current data is displayed for editing. If not found, a blank form is displayed to add a profile. Line 11 is just to display "Add Profile" or "Edit Profile" in the fieldset legend. The getSkillset() function runs a query to get all the skillset descriptions and matches the skillset_id against the user_skillset to get the current levels for the user for each skillset. It then loops through the results creating a new div for each specialization, and these divs contain the list of skillsets for the specialisation with their radio buttons (the buttons checked according to the users current level) The javascript is to hide/show the div relating to the selected specialization. I am attaching a dump of my test database Dump20150709.txt
  4. It may look more complicated but if your coding follows the db structure it's easier and requires far less code. I have attached a sample form and update using the proposed structure. As you can see it saves you hundreds of lines of repetitive coding. I don't what you want in the portfolio table but it sounds as though you treat it the same way as have with the user_skillset records (one image name per row, each with the user_id). For brevity, I omitted the picture upload. beginner_profile.php beginner_update.php
  5. If you only want to send a single SMS, why are fetching records for everyone that has due due dates then checking each one for the $current_visitor? Make it a condition in the WHERE clauses so you only get the data you need. BTW, $current_visitor doesn't appear to be defined anywhere.
  6. Given the structure of the data in your form, I would suggest that that your DB structure should be +----------+ +-----------------------+ | user | | specialization | +----------+ +-----------------------+ | id (PK) | | specialization_id(PK) | | name | | description | | email | +-----------------------+ | username | | | password | +-------------------+ +-------------------+ | +----------+ | user_profile | | skillset | | | +-------------------+ +-------------------+ | | | userProfileId(PK) | | skillset_id(PK) | | | | user_id | | specialization_id |>---------------+ +-----------------| picname | | description | | introduction | +-------------------+ | contactno | | +-------------------+ | | | | | | | | +-----------------------+ | | | user_skillset | | | +-----------------------+ | +--------<| user_id(PK) |>-----+ | skillset_id(PK) | | level | +-----------------------+
  7. Your form is missing the "Submit" button. When I added that there were no problems. I did not get your timeout error.
  8. Works fine for me. Post the whole code from your "index.php"
  9. The select needs to be inside <form> tags (hence my previous link to php forms). When the form is submitted the contents are passed in the $_GET or $_POST arrays depending on the form method. (Use POST when sending data to perform an update and GET when you just want to get information) include("class.php"); if (isset($_GET['year'])) { $f = new february((int)$_GET['year']); $days = $f->numdays(); echo "There were $days days in February {$_GET['year']}<hr>"; } $cutoff = date(1900); $now = date('Y'); ?> <html> <body> <form method='get' action=''> <?php echo '<select name="year">' . PHP_EOL; for ($y=$now; $y>=$cutoff; $y--) { echo ' <option value="' . $y . '">' . $y . '</option>' . PHP_EOL; } echo '</select>' . PHP_EOL; ?> <input type='submit' name='btnSubmit' value='Submit'> </form> </body> </html>
  10. http://uk1.php.net/manual/en/tutorial.forms.php
  11. This should get all the info you need with a single query instead of all those separate ones SELECT id, sloc.name as start, startcompany, eloc.name as end, endcompany, cargoweight, dc.name as cargo, cargotype, time, cargodamage, drate.name as rating, distance, price, costs, screenshot, status price - costs - cargodamage as profit FROM drive_routes as dr INNER JOIN drive_locations as sloc ON dr.start = sloc.id INNER JOIN drive_locations as eloc ON dr.end = eloc.id INNER JOIN drive_cargo as dc ON dr.cargo = dc.id INNER JOIN drive_rating as drate ON dr.rating = drate.id WHERE driver = ". $_GET['id'] ."
  12. The only loop I can see in the code is foreach($rows3 as $row){ Where is $rows3 defined?
  13. 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
  14. 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?
  15. 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);
  16. 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']); });
  17. 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
  18. Use PHP GD library and http://php.net/manual/en/function.imagerotate.php
  19. 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?"
  20. getImageSize() returns an array. eg list($width, $height, $type, $attr) = getimagesize("img/flag.jpg"); and you should be checking the uploaded tmp file.
  21. http://it2.php.net/manual/en/features.file-upload.multiple.php
  22. 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 | +----------------+
  23. I have done in the past but I am in the middle of creating a small application to automate the process
  24. +--------------+ +-----------+ +----------------+ +-------------+ | 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
×
×
  • 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.