Jump to content

leanchristmas

Members
  • Posts

    11
  • Joined

  • Last visited

leanchristmas's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Any chance that someone can help me with this ? Thanks in advance.
  2. Once again I need help. What I need is to change encoding to UTF-8. When I change encoding from UTF-8 without BOM to UTF-8 in Notepad++, for exampleForm.php, after I submit grades it doesn't reload page again but shows empty page and url bar shows exampleUpdate.php . Even if we ignore this, I can't change encoding. I tried via phpmyadmin and changed to utf-8 but attributes descriptions are still not showing properly. Basicily I need to change to utf-8 because attributes description are containing some eastern European characters.
  3. Great, I really appreciate your help. Thank you very much once more.
  4. Perfect, can't thank you enough. Just one final little thing, how to put result to 2 decimal as was before? Now is 4 decimal, I tried to find it in a code but couldn't. Many thanks
  5. No they don't need to log in. I attached table as an example. Marked with red are multiple grades, which should not be seen on the report, but should be calculated. Marked with black are average grades that should be presented in report. Hopefully I explain it alright.
  6. First of all thank you very much Barand, everything is working perfectly. Also, apology because I did not explain precise everything in the beginning. There's one thing I would like to change. My idea was to grade students multiple times, so everyone can give grades via browser, so after 20 people give their grades we can see report total of 20 grade entries. As I said, after multiple grading, I would like to see average grade for every student, for e.g. "Hair", and in the last column "Total average". As I could understand now is "Average" showing average of total grades, but grades for specific values are randomly presented?
  7. OK, great. But I'm still not sure in which files to put this code? How to organize everything? Keep it everything in one file?
  8. Thank you Barand, I see that now. I'm confused with code. In your first post you posted 4 blocks of code and attached example file. I'm not sure where to put which code, how to organize my files? How many of them should I have? Only two, one for inserting and one for reporting data?
  9. @ Barand, sorry to bother you again. I tried to do it your way but I'm little confused, I'm really beginner with a big B, so please have patience. I'll try to post what I have done so far. This is my .php file used to connect to db, it is not viewed in browser: <?php $server = "localhost"; $username = "xyz"; $password = ""123; //mysql server connection if (!$spoj=@mySQL_connect($server, $username, $password)) { die ("<b>Connection to DB error</b><br>"); } else{ echo "<b>Connected successfully, right DB.<b>" ; } //select DB if (!mySQL_select_db("xyz", $spoj)) { die ("<b>Connected successfully.</b><br>"); } else{ echo "<b>Connection error</b><br>" ; } $sql = "CREATE TABLE person ( persId INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) )"; $db->query($sql); $sql = "INSERT INTO person (name) VALUES ('John Doe'), ('Jane Brown'), ('Harry Potter')"; $db->query($sql); $sql = "CREATE TABLE attribute ( attrId INT NOT NULL AUTO_INCREMENT PRIMARY KEY, description VARCHAR(50) )"; $db->query($sql); $sql = "INSERT INTO attribute (description) VALUES ('Hair'), ('Clothes'), ('Education'), ('Other'), ('Etc')"; $db->query($sql); $sql = "CREATE TABLE rating ( ratingId INT NOT NULL AUTO_INCREMENT PRIMARY KEY, persId INT, attrId INT, rating TINYINT )"; $db->query($sql); ?> This is file that I want to use for selecting grades, of course it is viewed in browser. This is biggest problem for me, can't really understand how to connect choosing User ID and selecting it from DB, also how to connect ratings with DB: <?php include "spoj.php"; $sql = "CREATE TABLE person ( persId INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50) )"; $db->query($sql); $sql = "INSERT INTO person (name) VALUES ('John Doe'), ('Jane Brown'), ('Harry Potter')"; $db->query($sql); $sql = "CREATE TABLE attribute ( attrId INT NOT NULL AUTO_INCREMENT PRIMARY KEY, description VARCHAR(50) )"; $db->query($sql); $sql = "INSERT INTO attribute (description) VALUES ('Hair'), ('Clothes'), ('Education'), ('Other'), ('Etc')"; $db->query($sql); $sql = "CREATE TABLE rating ( ratingId INT NOT NULL AUTO_INCREMENT PRIMARY KEY, persId INT, attrId INT, rating TINYINT )"; $db->query($sql); // // define the options for the rating dropdowns // $ratings = "<option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option>"; // // use attribute table to build the rating selections // and alsoto store the headings for the report // $sql = "SELECT attrId, description FROM attribute ORDER BY attrId"; $res = $db->query($sql); $ratingSelections = ''; $attrs = array(); while (list($id, $des) = $res->fetch_row()) { $ratingSelections .= "<div class='descrip'>$des</div> <div class='rating'><select name='rating[$id]'>$ratings</select></div> <div style='clear:both'></div>"; $attrs[$id] = $des; // store heads for table } ?> <form method="POST" action="upis.php"> <Select ID <br /> <label for="select-choice"></label> <select id="selected" name="selected" class="select" value="test"> <option value="persId">John Doe</option> <option value="persId">Jack Jonhson</option> <option value="persId">John Jackson</option> </select> <input type="submit" value="Upis" name="upis"> <br> </form> This is .php file I want to use for submitting ratings, not viewed in a browser: <?php include "spoj.php"; if (isset($_POST['persid'])) { // id of person being rated $persid = intval($_POST['persid']); // insert a row for each attribute into rating table $data = array(); foreach ($_POST['rating'] as $attrid => $rating) { $data[] = sprintf("(%d, %d, %d)", $persid, intval($attrid), intval($rating)); } $sql = "INSERT INTO rating (persId, attrId, rating) VALUES " . join(',', $data); $db->query($sql); } ?> This is .php file used for presenting data from DB, of course viewed in browser. Big problem for me is how to present this data in a browser: <?php include "spoj.php"; $query="SELECT * FROM rating"; $q=mysql_query($query); if (mysql_num_rows($q)==0) { echo "There is no data in table!"; } else { /// I know I need rows names etc, but not sure how to do it! ?> I did not paste HTML code, assuming it is irrelevant. Connection with server and DB is OK, but I can't get tables inserted into DB. I know this is not the best way to design whole process, but it's the best I could make. Hopefully you can help me. Thanks.
  10. Thank you very much, both of you. I think I'll go with Barand's solution, but I really appreciate your effort Ch0cu3r. So I'll try to do it as Barand suggested, assuming I'll get stuck at some point I will ask for help again. Once more, thank you very much both of you.
  11. Hello to everybody great community, I'm a beginner and I'm only familiar with basics of HTML, CSS and PHP. I'm working on small project and I could really use some help. So far I made web site with possibility to enter values into MySql table and to show this values(read it from table) on another page, As I sad would like to do something little more complex (at least is copmlex for me). What I want to do is something like very simple rating system: Choose ID via "select-choice" or similar line. So if I choose ID=JohnDoe, then all the grades I submit should be submitted only for this ID. I know how to make selection choice but I don't know how to connect it to save it to database/table. Only offered ID's should be available to select After ID is selected (JohnDoe) I would like 4 various grades options, each one is graded 1 to 5. Example: hair grade(1-5), clothing grade(1-5), education grade (1-5) etc. Option to submit and save grades into database, as I said it should be saved only for selected ID. On the new web page show results from table. Results should be presented separately for each ID. And in the last column average grade it should be shown. I have attached screenshot so you can see how I have pictured it. The main problem for me is how to submit grades to table and how to make sure grades are submited onyl to selected ID. Sorry for my English, hopefully I managed to explain problem. Many thanks in advance!
×
×
  • 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.