[Solved] How to make HTML interact with a database? [closed]

You can’t make HTML directly interacting with database. You should create server-side application, which answer queries generated by HTML forms, JS queries, etc. I am PHP developer, I like this language, so I recommend you using it in your solution. You can read about connecting PHP to MySQL database here: http://www.w3schools.com/php/php_mysql_connect.asp There you have basic … Read more

[Solved] How to edit my code to save to mySQL from the beginning of XML?

This should work for you: <?php //Xml stuff $xml = simplexml_load_file(“file.xml”); //Database stuff $hostname = “localhost”; $username = “root”; $password = “”; try { //DB Connection $dbh = new PDO(“mysql:host=$hostname;dbname=dbname”, $username, $password); $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); echo “Connected to Database<br/>”; foreach($xml->products->product as $data) { $sql = “INSERT INTO XML_FEED (shop, product_id, product_name, product_link, product_image, product_category, product_price_with_vat) VALUES … Read more

[Solved] How to find the number of correct answers that user had made then convert the correct answer to percentage? [closed]

Firstly, declare some variables to work with for your test. Integer userScore=0; Integer totalScore=0; The percentage is userScore/totalScore*100. To add these up throughout the test, each of your questions should have something like this in them. if (answerIsCorrect) { userScore++; } totalScore++ To get the percentage, you just need to use your variables that have … Read more

[Solved] java servlet programming error [closed]

Need to put the servlet.jar in your CLASSPATH when you compile. The servlet.jar is part of Tomcat. You’ll probably find it in servlet/lib on version 5.5. You should know how to use -classpath option on javac.exe. You’ll probably find that there are other JARs missing as well. As you get compilation errors, keep finding the … Read more

[Solved] how to remove the space between the two triangle?

In the first for loop. Do not put i <= n but i < n and the space will dissapear. Try to figure out yourself why this is. Correctly formatted (also removed the input scanner line). public class series { public static void main (String args[]){ int n=5; if((n>=1 && n<=9)){ for(int i=0;i<n;i++){ //spacing logic … Read more

[Solved] How to create a Sports Bet Calculator using javascript

Revised first version 🙂 const bt_Nwline = document.getElementById(‘New-Line’) , xForm = document.getElementById(‘form-X’) , wTable = xForm.querySelector(‘table’) , baseLine = wTable.querySelector(‘thead tr:nth-of-type(3)’) , tBody = wTable.querySelector(‘tbody’) , tPayout = wTable.querySelector(‘tfoot td:nth-of-type(2)’) ; xForm.onsubmit = e=>e.preventDefault() // disable form submit ; xForm.onreset =_=>{ tPayout.textContent=”0.00″ } ; function betCalculator() { let bet = xForm.betAmount.valueAsNumber || 0 , odds … Read more

[Solved] First time to query 3 mysql tables [closed]

You have to use 2 joins to link these 3 tables. INNER JOIN means, that only those tuples are listed, for which an correct tuple exists in every table. Students without subjects or wrong subject_ids will not be listed. Keep in mind, that an student, which visits X subjects will also listed X times. SELECT … Read more

[Solved] How can show unlimited parent-child & sub-child tree data in laravel

you need to fetch all the products in one query and then process them to build the tree. You cant eager load it the traditional way. Original solution from Formatink public function products($projectId) { $products= Product::where(‘project_id’, $projectId)->get(); $products_by_id = collect(); foreach ($products as $product) { $products_by_id->put($product->id, $product); } foreach ($products as $key => $product) { … Read more

[Solved] How to rename last letter but not the file ending in python [duplicate]

Do something like this >>> import os >>> for root, subFolders, files in os.walk(‘/tmp’): … for f in files: … if len(f) < 5: continue … newf = f[:-5]+f[-5].lower()+f[-4:] … print “changing”,f,”to”,newf … but looks like you want character before extension instead of 5 char? in that case why not just split the extension from … Read more