Jump to content

richarro1234

Members
  • Posts

    146
  • Joined

  • Last visited

Everything posted by richarro1234

  1. oh right ok, didnt even know you could do that.....thanks, i will hopefully leave you alone now, thanks for all the help.
  2. ooo right i see, i think i get it now. is that the best way of doing it though? as in if i have 10 users who have completed 59 of the 60 items each, thats 590 records in 1 db? surely that would get big quick, say if 100 people used it 5900 records thats a fairly big db??
  3. hmmm, just been looking at the code and such like, but what happens if they then mark the same as completed, like say user 1 and 2 marks item 2 as completed, the way its set up doesnt look like it would work, surely it would replace the current number in user_id?
  4. ooo right i see, ok thanks very much sorry for all the hassle does date completed have to be a timestamp though or can it be a Boolean?
  5. thanks barand, still doesnt really solve the problem though.... (unless im just not understanding it) ill try to explain a different way.. a user comes and joins this website, there is 1 list of items to complete (100% checklist) each user that joins has the same list of items to complete. so the list needs to be made, every time a user joins the site and store only what they tick off. E.G im on the site, i complete tasks 1-5, barand, you join the site and the same list (everything unticked) appears on your screen have done tasks 2-7 so you tick them off, then when you come back on the site, you tasks 2-7 are still ticked off and when i come on my 1-5 are ticked off. so everyone has there own list of the same items which is unique, individual, personal only to that user. Hope that cleared things up abit and if its still the same answer then fine, let me know Thanks Rich
  6. its actually different. this was about making the ajax/jquery calls and having it change to a tick or something saying it was completed, the other post was about php and mysql on how to make the same list appear for all users and make it so it was a personal list rather then having 1 list show for everyone. just whilst were being snarky
  7. Ok any ideas how I would go about doing that with the code I have? Don't want to mess too much up and if I start playing with bits I don't know then I'm sure to break it
  8. Hey thanks for the replys. The problem is it's the same list for everyone. It's a 100% checklist so it's the same list for every person but each person will have completed different things to everyone else so needs to be the same list unique to each person so it doesn't really matter about when it was done. It just needs to be a unique list for everyone who signs up without having a massive database.
  9. Hey, thanks for the reply. How would i add that to this though? <?php if(isset($_POST['submit'])) { $addId = -1; if(isset($_POST['content'])) { foreach($_POST['content'] as $id => $content) { if(!is_int($id)) { header('HTTP/1.1 400 Bad Request'); die('Invalid item ID.'); } if($id === -1 && !empty($content)) { $query = $link->prepare('INSERT INTO todo(`done`, `user`, `text`) VALUES(0, :user, :text);'); $query->execute(array( ':user' => $user, ':text' => $content )); $addId = $link->lastInsertId(); } else { $query = $link->prepare('UPDATE todo SET `text` = :text WHERE `id` = :id AND `user` = :user LIMIT 1;'); $query->execute(array( ':id' => (int)$id, ':user' => $user, ':text' => $content )); } } } $query = $link->prepare('UPDATE todo SET `done` = 0 WHERE `user` = :user'); $query->execute(array(':user' => $user)); if(isset($_POST['done'])) { foreach($_POST['done'] as $done) { if(!ctype_digit($done) && $done !== '-1') { header('HTTP/1.1 400 Bad Request'); die('Invalid item ID.'); } if($done === '-1') { $done = $addId; } $query = $link->prepare('UPDATE todo SET `done` = 1 WHERE `id` = :id AND LIMIT 1;'); $query->execute(array(':id' => (int)$done)); } } } $query = $link->prepare('SELECT * FROM todo WHERE `user` = :user ORDER BY `id` ASC;'); $query->execute(array(':user' => $user)); ?><!DOCTYPE html> <html> <head> <!-- Page title --> <title>My list · TODO:</title> <!-- Stylesheets --> <link rel="stylesheet" type="text/css" href="stylesheets/default.css" /> <link rel="stylesheet" type="text/css" href="stylesheets/todo.css" /> <!-- Scripts --> <script type="text/javascript" src="scripts/json2.min.js"></script> </head> <body> <form method="POST" id="content"> <h1>100% CheckList</h1> <ul id="todo-items"> <?php while($row = $query->fetch()): ?> <li> <input type="checkbox" name="done[]" value="<?= $row->id ?>" class="done-box"<?php if($row->done): ?> checked="checked"<?php endif; ?> /> <span class="content"><?= htmlspecialchars($row->text) ?></span></li> <?php endwhile; ?> </ul> </form> <script type="text/javascript" src="scripts/todo.js" async="async"></script> </body> </html> without messing toooo much up? ive never used joins before and although im sure its fairly easy to most people. Rich
  10. Hey, So, im creating like a checklist of items that need to be done. Now, i have the list of items, but its the same list for every user (they have to login to see the list) What i need is a way so that it stores just that users completed items (my list works at the moment with just 1 user. when i mark an item as complete it crosses it out so its done) but then if another user come sonline and looks at the list it will show (my) list and will say itesm are done if they havent done them. So what i need to know is what is the best way to store the data and how do i do it? i thought about adding rows to the user table for each of the items, but theres 60 on the list (and it might grow) so didnt think that would be very efficient. the list is marked completed by ajax/jquery so needs to accommodate that too. If anyone is confused by this (like me) then please let me know and i will try to explain better Thanks Rich
  11. Hello there, Im trying to create a list of items that appear for a user (abit like a todo list) i have them all added to the DB and displaying on the page. Im also trying to make it so there is a checkbox next to the item on the list and they can check it and it will update instanly without having to change page, it will instead change to a tick rather then a checkbox, then if the page gets reloaded by the user i can add some php code so it will say complaeted or show a tick depending on the answer in the database. Now the problem is i cant seem to find any thing that works like that and wondered if anyone had something similar or knew some code to make it work? the list is stored in the DB with just an A.I number and the name of the item and im using the item ID to save which items have been completed and which ones havent. So also, how would be the best way to store such data (which user has completed it and who hasent, without having a seperate entry in the database for each user and each item (theres 60 items on the list) Thanks Rich
  12. Awesome, Thank you very much DavidAM works a charm... Thanks so much Rich
  13. <?php $mysql_hostname = "localhost"; $mysql_user = ""; $mysql_password = ""; $mysql_database = ""; $bd = mysql_connect($mysql_hostname, $mysql_user, $mysql_password) or die("Could not connect database"); mysql_select_db($mysql_database, $bd) or die("Could not select database"); ?> <?php $results= mysql_query("SELECT * FROM hours WHERE year = '2010'"); echo mysql_error(); if (mysql_Numrows($results)>0) //if there are records in the fields { $numrows=mysql_NumRows($results); //count them $x=0; while ($x<$numrows){ //loop through the records $thetimein=mysql_result($results,$x,"timein"); $thetimeout=mysql_result($results,$x,"timeout"); $theday=mysql_result($results,$x,"daynumber"); $themonth=mysql_result($results,$x,"month"); $theyear=mysql_result($results,$x,"year"); $worked = $thetimeout-$thetimein; $totalpay = $worked*6.40; ?> <?php echo" $theday/$themonth/$theyear: $thetimein - $thetimeout ($worked) = (£$totalpay)"; ?><br> <?php $x++; } } ?> <BR> Total pay so far is: <?php echo"$totalpay"?> Thats the code i have so far The question is: How do i do it please. Rich
  14. Hey all, im trying to make a script that will show the hours i have worked and how much i get for that day, then i need to add all the days up and output the total at the bottom of the page. So say i get £5 an hour and i do 4 hours one day 1 and 5 hours on day 2 So far the database outputs all the data like this: day1 - in 12:00, out 16:00 (hours) (£20) day2 - in 12:00 out 17:00 (5hours) (£25) now i need to add up the total for each day and output the grand total (so 20+25=£45) But i also need it to be able to add if i add a day aswell so day3 - in 12:00 out 17:00 (5hours) (£25) so now the total at the bottom of the page would be £70 Hope this makes sense to everyone, i have my code if anyone needs to see it. Thanks Rich
  15. this is the one i found: http://www.mperfect.net/barCode/ scroll down to where it says "web interface" upload any image of a barcode and it will show the numbers from it, so there is one somewhere, but this one doesnt have a download section or anything where i can get this script.
  16. Hey there, im trying to find a PHP script where i can scan an image of a barcode and have it show up the number from the barcode, i have found one so far, but there is no download for it. Does anyone know where i can find such a script or does anyone know how to code such a script that i can use on my website. Thanks Rich
  17. @mchl: 1,2, i had a constant but it just came up with "could not find constant", and now i know why. 3 i thought could only be used when inserting data into a databse, but will give it a go and see what happens @businessman: thanks for clearing that up. Thanks for your help guys Rich
  18. Hello, Im trying to change some info that has been output from the database, basically its an interview, and i would like to change the color of the names being output from the database using define. <? session_start(); include("dbconfig.php"); ?> <? $query = mysql_query("SELECT * from interviews WHERE bid = '".$_GET['id']."'"); while ($b = mysql_fetch_array($query)) { $intid = $b['id']; $interview = $b['interview']; $bandid = $b['bid']; $location = $b['location']; $date = $b['date']; } define("E.G.G","<font color=\"ff0000\">E.G.G</font>"); ?> <? include ("header.php"); ?> <div id="mainCont"> <div id="leftCol"> <div id="bandinfo"> <h3>Location: <?=$location?></h3> <p><? echo $interview; ?></p> </div> </div> <div id="centrCol"> <div id="albmBlock"> But this doesnt change the color of "E.G.G". Is there away to do this without having to go into phpmyadmin and adding the <font> tage to every name in there as it is quite a long peice of text? Thanks Rich
  19. Yea ive got that at the moment, but its not showing up the second demand on the website.
  20. Hello, Im trying to setup something with a supply and demand schema. for example: i buy a business and it supplies item 1,4 but it demands item 2,3,5 (like a grain mill requires grain, to produce flour) But im not sure how to go about setting this up. Can someone please help me set this up so that i can add businesses to a database and have the supply number and demand number for that business and then have it display the name of the item on the web page. Thanks Rich
  21. Thanks for the reply, it has the percentage, but for some reason, just after it levels up the percentage starts at 80% instead of 0%. am i missing something? Thanks Rich
  22. Hello, So heres my problem: im trying to create a level system, so that when people do something on the site they gain XP, each level is set out in the database as such: _______ |xp | lvl | | --- |---| |100| 1 | |150| 2 | |300| 3 | |450| 4 | |700| 5 | etc etc... So that if you have that amount of xp or greater, then your that lvl (I.E i have 160 xp im lvl 2) Now, im trying to create a bar underneath it to show the percentage you have completed I.E. you have 25 xp the bar needs to show 25% of the bar full ive managed to get it to show the ammount of xp you need untill the next level, but im not sure how to convert that into a percentage and add it to the bar. Can someone help me with this please. Thanks Rich
  23. sorry, thought i put i couldnt find any working
  24. well i dont know how to do that, couldnt find any working examples.
  25. because its in a different place. Its a game, so the money and user stats is in a bar at the top of the page.
×
×
  • 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.