Jump to content

Recommended Posts

Hello!

 

I would like to do a page with something like quiz. "Quiz" will have questions and then there will be check boxes below it(around 15). And regarding ticked boxes page will show result(s) from base. I already did 3 tables in mysql but I dont know how to write the coding.

 

Could somebody help me?

 

klodovik

Link to comment
https://forums.phpfreaks.com/topic/183118-diagnosis-application/
Share on other sites

but I dont know how to write the coding

If you aren't a programmer then I suggest you get a book on php website development. You will not get help in the forum unless you show that you have the ability to lay down the basic code and logic.

If you need this developing for you then I suggest you post in the relevent section.

  • 2 weeks later...

Here is the code, whats wrong?

I would be very happy if somebody would answer.

http://martinfrelih.com/test/phptest.php

 

<html>
<head>
<title>test stran</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div align="center" id="container">
<?php
// Make a MySQL Connection
mysql_connect("localhost", "username", "password") or die(mysql_error());
mysql_select_db("martinfr_baza1") or die(mysql_error());

// Get all the data from the "example" table
$result = mysql_query("SELECT * FROM property") 
or die(mysql_error());  

echo "<table border='1'>";
echo "<tr> <th>Id number</th> <th>Title</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>"; 
echo $row['id'];
echo "</td><td>"; 
echo $row['title'];
echo "<input name='property[]' type='checkbox' value='id'>";
echo "</td></tr>";

} 

echo "</table>";
echo "<input name='send' type='submit' id='send' value='Send!'>";
echo "<br />"; 


$result = mysql_query("SELECT * FROM item") 
or die(mysql_error());  

echo "<table border='1'>";
echo "<tr> <th>Id number</th> <th>Title</th> </tr>";
// keeps getting the next row until there are no more to get
while($row = mysql_fetch_array( $result )) {
// Print out the contents of each row into a table
echo "<tr><td>"; 
echo $row['id'];
echo "</td><td>"; 
echo $row['title'];
echo "</td></tr>"; 
} 

echo "</table>";


$countmatch = array(); 

// v $allItemProperties moraĹĄ immeti vse lastnosti iz tabele ItemProperty
foreach($allItemProperties as $item){
if(isset($_POST["property"][$item["property_id"]])){ // Äe obstaja(je oznaÄena) lastnost.

$countmatch[$item["item_id"]]++; // poveÄaj ĹĄtevec za trenutni sladoled
}
}
$result = mysql_query("SELECT * FROM item_property") 
or die(mysql_error());  


while($row = mysql_fetch_array( $result )) {

if(isset($_POST["property"][$row["property_id"]])){ // če obstaja(je označena) lastnost.

$countmatch[$row["item_id"]]++; // povečaj števec za trenutni sladoled

}

}

// sedaj imaĹĄ urejena ujemanja in moraĹĄ samo ĹĄe poiskati kateri sladoled ima najboljĹĄe ujemanje.



$maxCount = 0;
$maxCoundItemId=null;

foreach ($countmatch as $key=>$value) {

if($value>$maxCount){
$maxCount=$value;
$maxCountItemId = $key;
}


}

echo "$maxCountItemId";






?>



</div>
</body>
</html>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.