Jump to content

Barand

Moderators
  • Posts

    24,563
  • Joined

  • Last visited

  • Days Won

    822

Everything posted by Barand

  1. Contact the printer manufacturer, they may aleady have android software and cable available for this purpose.
  2. I'm guessing the assignment deadline has passed, so for the sake of others reading the thread, here's one solution... <?php $a = 1; $b = 2; $c = []; $d = []; $N = 8; $tdata1 = $tdata2 = ""; $vals = []; for ($i=1, $a=1, $b=2; $i<=$N; $i++, $a+=2, $b+=2) { $c[] = $a; $d[] = $b; $exp = '<u>' . join('.', $c) . "</u><br>" . join('.', $d); $tdata1 .= "<td>$exp</td>"; $val = number_format(array_product($c) / array_product($d), 5) ; $tdata2 .= "<td>$val</td>"; } ?> <table border='1'> <tr><th>Fraction</th> <?=$tdata1?> </tr> <tr><th>Decimal</th> <?=$tdata2?> </tr> </table>
  3. FYI - 8 queens solution... The Pythagorean numbers were as much use as a chocolate teapot
  4. <!DOCTYPE html> <html lang="en"> <head> <title>4 Queens</title> <meta charset="utf-8"> <style type='text/css'> table { border-collapse: collapse; } td { width: 40px; height: 40px; text-align: center; font-size: 16pt; } tr:nth-child(odd) td:nth-child(even), tr:nth-child(even) td:nth-child(odd) { background-color: lightgreen; } </style> </head> <body> <?php echo '<table border="1">'; for ($i = 1; $i <= 4; $i++) { echo "<tr>"; for ($j = 1; $j <= 4; $j++) { echo '<td>' . pow($i,2) + pow($j,2) . '</td>'; } echo '</tr>'; } echo "</table>\n"; ?> </body> </html> Dear Supreme Being, Can you put aside your arrogance for a moment and assume that we are 5 year olds (not a wall) and explain the theory behind your Pythagorean solution to the problem and why it "works" explain how the above square then tells us where the four queens should be positioned? I've found the 5s but there are no "opposite 10s", only 20s opposite the 5s, so the description is somewhat vague.. Having found the 5s, 10s, 20s and 25s (why those values in particular?), I now have 8 squares. Given that these are the candidates, the code then needs to find which 4 of these 8 fit the bill.
  5. INSERT INTO user (fname,sex) values (inname, NULLIF(insex, '') );
  6. In your php.ini file, ensure "display_startup_errors" is also set to On
  7. Why the Freckle didn't you post the code that actually used to get the results you are complaining about. Once I got the data loaded, your query wouldn't even run without corrections to column names. Anyway - the answer to your question... They are in the wrong order because you order by your generated qNo column. I'd give up on that method. If you are using MariaDB, you can ORDER BY NATURAL_SORT_KEY(Q_id) If MySQL (which doesn't have that function), use FetchAll() to get an array of your results then natsort($results) use a custom sort which does a strnatcmp() on the Q_id column $res = $pdo->query(" ... "); $result = $res->FetchAll(); usort($results, fn($a,$b)=>strnatcmp($a['Q_id'], $b['Q_id'])); (Using sort($results) would have sorted using the values of the first column in each row - I assumed natsort() would do the same (silly me) )
  8. FYI - it helps if the column defined as the primary key exists in the table! Same goes for the unique key in user table. Plus other syntax errors - I was trying to help but I gave up.
  9. Your main problem is that mysql_*** functions have been deprecated for years and now no longer exist (unless you are using a really ancient version of PHP, in which case you should upgrade) You need to use mysqli or PDO (PDO is definitely recommended).
  10. I gained four inches just by giving up rugby, squash and badminton.
  11. If it's your homework assignment, yes. If it isn't, what have you tried so far?
  12. Here's a cycle you can use to do your homework
  13. If you want to add another key to the results array add it to the query, and use @mac_gyver method.
  14. ... or ... $res = $pdo->query("SELECT Lvl , Sub FROM shadd_1 ORDER BY Lvl DESC, Sub "); $results = $res->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_COLUMN); foreach ($results as $lvl => $arr) { echo "$lvl <UL>"; foreach ($arr as $sub) { echo "<li>$sub</li>"; } echo "</ul>"; } FYI - the $results array (slightly simpler than the $data array in above post) looks like this.. Array ( [ULE] => Array ( [0] => BASIC lug [1] => BASIC lug ) [ACE] => Array ( [0] => ger ) )
  15. And what are you wanting to do with that table? BTW, which values belong to which columns (do you have a problem with your keyboard's spacebar? If so you could have used the "table" button in the toolbar) What code have you tried so far?
  16. Store the completion time instead of the duration. Count down until the end time is reached. My usual method is to store a variable in a hidden input field in PHP then access that field's value from javascript.
  17. Check the number of rows affected by the query. https://www.php.net/manual/en/mysqli.affected-rows.php
  18. @Psycho the PDO result/statement object is traversable whether you use query() or execute(). The mysqli result object is traversable (when the result of a query) but the statement object as a result of execute() is not (as well as having a different set of methods to process). This adds to my theory that mysqli result class and statement class were developed by two teams who never spoke to one another. EG $res = $pdo->query("SELECT name FROM reindeer"); foreach ($res as $r) { echo $r['name'] . "<br>"; } results... Comet Cupid Dasher Vixen Prancer Dancer Donner Blitzen
  19. Don't use "select *". Specify the columns you need. Then use a foreach loop, not a for loop. Don't embed variables in the sql string, use prepared queries with placeholders, then execute with the variables passed as parameters. $sql_list = "SELECT ID FROM dados_socios WHERE usuario = ? ORDER BY ID"; $result_list = $conn->prepare($sql_list); $result_list->execute([$usario]); echo "<select>"; foreach {$result_list as $row) echo "<option>ID: {$row['ID']}</option>"; } echo "</select>";
  20. PHP runs on the server. - Javascript runs on the client. On completion of the PHP it sends the page to the client where the javascript runs. At the time you "echo $array;" the js variable "i" does not yet exist. (Error thrown if turn on error reporting) By the time the javascript runs "$array" no longer exists.
  21. Check the output from phpinfo() to make sure the php.ini file you edited is the one currently being used.
  22. I agree those are sufficient to define and draw the cell connections but, to be able to trace the paths through the network, it's a lot easier to know that A connects to B and also that B connects to A - that requires the top and left ones too. The database gave me an easy way to check for uniqueness and that I wasn't just recreating the same grid over and over.
  23. With a little experimentation you could answer those questions yourself.
  24. Looks very much like this... https://forums.phpfreaks.com/topic/323782-how-to-loop-through-array/?do=findComment&comment=1634454
×
×
  • 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.