Jump to content

Barand

Moderators
  • Posts

    24,566
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Create you own topic. Don't just tack your question on the end of someone else's. EDIT: You have $_POST['username'] but the form field has name='name'
  2. The first thing you need to do is break up that compound period column - you have three items in there that should be in separate columns Day number (1 - 7) Week (YYYYWW) Session number You will also need a session table containing five rows, one for each session 1 - 5. Your query needs to know what should be there if it wants to show you what is missing.
  3. In your other topic I showed you how to read the files and pick out the numbers and text. However you have now changed the format of that file to make it much more difficult. You also wanted to write that file to a database table and now you want to put it in a form. When you have made up your mind exactly what you do want, let us know. After all, you don't want to waste any more of our time, do you?
  4. Not from the paltry amount of information you have given us so far
  5. If you are storing the data in a database table then you do not want to ignore the subject, you want to store it with the marks. Something like this will do it // // CREATE THE TABLE // $pdo->exec("DROP TABLE IF EXISTS mark"); $sql = "CREATE TABLE mark ( mark_id int not null auto_increment primary key, subject varchar(20), term tinyint, marks int )"; $pdo->exec($sql); // // PROCESS THE DATA // $insertSql = "INSERT INTO mark (subject, term, marks) VALUES (?,?,?)"; $stmt = $pdo->prepare($insertSql); $data = file('marks.txt',FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $subject=''; foreach ($data as $val) { if (!ctype_digit($val)) { $subject = $val; // if not a number, store subject $term = 1; // reset term number } else { $stmt->execute([$subject, $term++, $val ]); // insert record } } results: mysql> SELECT * FROM mark; +---------+-----------+------+-------+ | mark_id | subject | term | value | +---------+-----------+------+-------+ | 1 | Math | 1 | 80 | | 2 | Math | 2 | 55 | | 3 | Math | 3 | 90 | | 4 | Economics | 1 | 59 | | 5 | Economics | 2 | 22 | | 6 | Economics | 3 | 60 | | 7 | English | 1 | 83 | | 8 | English | 2 | 68 | | 9 | English | 3 | 76 | +---------+-----------+------+-------+ 9 rows in set (0.00 sec)
  6. Doesn't the week type tell you if it's week A, B or H? I still don't wee what the week name is for. Have you sample data.
  7. Week name? Do you really name your weeks? I would have expected to see a DATE field in that table, and in the mistable (booking) table too.
  8. What does "MONA:2" mean?
  9. You aren't process the array at the correct level. Add the line indicated to view the array key. You should have keys0, 1, 2, .... $this_temp_array = $results->Messages; foreach ($this_temp_array as $key => $value) { echo "Key is: $key<br>"; // <-- add this to get a clue if ($key == $n) $Message = $value; //print_r ($Message); $MessageID = $Message->Message->MessageID; $n=$n+1; echo $MessageID; }
  10. $xml = simplexml_load_string($responseXml); foreach ($xml->Messages->Message as $mes) { echo $mes->MessageID . '<br>'; }
  11. Sorry. Plan B echo "<pre>" . htmlentities($responseXml) . "</pre>";
  12. $results = new SimpleXMLElement($responseXml); There's a good chance that it is in $responseXml echo "<pre>$responseXml</pre>";
  13. Can you post the original XML data
  14. If you add 100 new ones every second you are in danger of running out of numbers in only 2,924,712,086 years
  15. $mysqli->query("SET ...") where $mysqli is the mysqli connection object.
  16. In the PHP, create an array to store the content destined for each div. Return the json-encoded array <?php // set up an array to hold the // contents of the divs $results = []; // get contents for div A and store in the array $results['A'] = "Contents of div A"; // get contents for div B and store in the array $results['B'] = "Contents of div B"; // JSON encode the array and send echo json_encode($results); ?> In the AJAX call, populate the divs from the returned response // ajax call $.get ( "my_ajax.php", function(data) { $("#divA").html(data.A); // put results into their $("#divB").html(data.B); // respective divs }, "json" )
  17. When you first load the page, no data has been posted. You need to check if the data has been sent and process the data only if it has if ($_SERVER['REQUEST_METHOD']=='POST') { // form processing code goes here }
  18. Have you tried using simpleXML? http://uk1.php.net/manual/en/simplexml.examples-basic.php
  19. Use a recursive function EG $dir='path/to/folder'; $results = []; getFiles($dir, $results); // show results echo '<pre>', print_r($results, 1), '</pre>'; function getFiles($dir, &$results) { $d = dir($dir); while (false !== ($entry = $d->read())) { if ($entry=='.' || $entry=='..') continue; if (is_dir($dir.'/'.$entry)) { getFiles($dir."/$entry", $results['folders'][$entry]); } else $results['files'][] = $entry; } $d->close(); }
  20. You can't. You would have to use clientside processing, such as javascript.
  21. I suspect it's because it uses "complex string syntax", just as $str = "ABC{$array[1][2]}"; requires the {..} whereas $str = "ABC$array[3]"; does not. http://uk1.php.net/manual/en/language.types.string.php#language.types.string.parsing
  22. Use braces $string2="foo: {$obj->p2->p21}";
  23. If it were your own code you'd know exactly why it was there. It seems your idea of "programming" is to copy bad code from from the internet and, when it doesn't do what you want, post it here for us to get it working for you. That being the case, thank you for moving on elsewhere. On the other hand, if and when you get serious about learning, we'll be happy to help.
  24. Sorry for pointing out those unnecessary aspects of your code. I was merely asking why you thought the concatenation of the empty strings was required. No rudeness was intended, unlike your response. I appreciate you must feel an absolute idiot right now, and I am sure no one will deny that you have every right to do so. After all, it was your code so no one else is to blame. Your subsequent petulant behaviour and hurling of profanities at other members (against forum rules by the way) merely reinforces that opinion.
  25. The question is if (!isset($_GET[''.$LINK_NAME.''] ^ ^ | | +------------+-- WTF are these for?
×
×
  • 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.