Jump to content

idire

Members
  • Posts

    98
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

idire's Achievements

Member

Member (2/5)

0

Reputation

  1. Yeh i guess, I already run an XAMPP server, but my internet connection isnt reliable enough to be able to permenantly host websites. and budget is pretty limited, how much is the cheapest dedicated hosting? I'd just be happy with a shared host that had external file access really, thats the most essential requirement, as i'm working with RDF XML files.
  2. Trying to find a UK web host, but having problems as I keep getting things missing. I need: Ability to access external PHP files - [ e.g. file_get_contents() ] - blocked by so many hosts.. PHP/MySQL Cron - unlimited number of tasks External access to MySQL databases Ability to change timezone default in PHP to GMT (or have it GMT already) php mail. Had some other requirements, but cant think of them at the moment, I primarily want to use the site for development and testing, I am working on several dynamic PHP projects, they require self updating by cron tasks. Currently using Godaddy primarily because it allows external file access, but it restricts alot of features, and its not UK currency. Current hosting bill converted is about ~£6 a month, for shared linux hosting Thanks
  3. Have muddled a solution with an if function checking for the first key in the array. Seems to work Thanks for the help all. $temp = key($value); if($temp != $firstkey) { echo '<h1>Question '.$temp.'</h1>'; }
  4. I did this: <?php foreach($answers as $data) { //for each question //print_r($data); foreach($data as $key => $value) { $firstkey = key($value); //echo $firstkey; //print_r($value); echo 'Question: '.$firstkey.'<br/>'; echo 'Answer: '.$value[$firstkey].'<br/>'; echo 'Number of responses: '.$value[NB]; echo '<br/><br/>'; } //new row echo '<br/>'; } ?> This gives me: Question: A1 Answer: 50 Number of responses: 2 Question: A1 Answer: 100 Number of responses: 2 Question: A2 Answer: 4 Number of responses: 2 Question: A2 Answer: 5 Number of responses: 2 etc now just have to find out a way of grouping the answers into a new array which maps question name -> multiple ( answer + nb of responses )
  5. Yes, i used that and got the same result as using foreach ($data as $value) e.g.: foreach($answers as $data) { //print_r($data); foreach($data as $key => $value) { print_r($value); //echo 'Answer: '.$value[A1].'<br/>'; //echo 'Number of responses: '.$value[NB]; echo '<br/><br/>'; } echo '<br/>'; } gives: Array ( [A1] => 50 [NB] => 2 ) Array ( [A1] => 100 [NB] => 2 ) Array ( [A2] => 4 [NB] => 2 ) Array ( [A2] => 5 [NB] => 2 ) Array ( [A3] => 3 [NB] => 1 ) Array ( [A3] => 5 [NB] => 3 ) what i need to echo is basically. On question A1 2 people answered 100, and 2 people answered 50.
  6. I'm trying to get the results of a questionnaire out onto the page. The two pieices of data I am concerned with are: the question name the number of people who chose that answer. I originally had this array: print_r($answers); Array ( [0] => Array ( [0] => Array ( [A1] => 50 [NB] => 2 ) [1] => Array ( [A1] => 100 [NB] => 2 ) ) [1] => Array ( [0] => Array ( [A2] => 4 [NB] => 2 ) [1] => Array ( [A2] => 5 [NB] => 2 ) ) [2] => Array ( [0] => Array ( [A3] => 3 [NB] => 1 ) [1] => Array ( [A3] => 5 [NB] => 3 ) ) [3] => Array ( [0] => Array ( [A4] => 3 [NB] => 2 ) [1] => Array ( [A4] => 5 [NB] => 2 ) ) [5] => Array ( [0] => Array ( [b2] => 2 [NB] => 1 ) [1] => Array ( [b2] => 3 [NB] => 2 ) [2] => Array ( [b2] => 4 [NB] => 1 ) ) [6] => Array ( [0] => Array ( [b3] => 3 [NB] => 3 ) [1] => Array ( [b3] => 4 [NB] => 1 ) ) [8] => Array ( [0] => Array ( [C2] => 1 [NB] => 1 ) [1] => Array ( [C2] => 3 [NB] => 1 ) [2] => Array ( [C2] => 4 [NB] => 2 ) ) [10] => Array ( [0] => Array ( [C4] => No [NB] => 2 ) [1] => Array ( [C4] => Yes [NB] => 2 ) ) [11] => Array ( [0] => Array ( [D1] => 4 [NB] => 2 ) [1] => Array ( [D1] => 5 [NB] => 2 ) ) [12] => Array ( [0] => Array ( [D2] => 4 [NB] => 2 ) [1] => Array ( [D2] => 5 [NB] => 2 ) ) [13] => Array ( [0] => Array ( [D3] => 3 [NB] => 2 ) [1] => Array ( [D3] => 4 [NB] => 2 ) ) [14] => Array ( [0] => Array ( [D4] => 2 [NB] => 1 ) [1] => Array ( [D4] => 4 [NB] => 1 ) [2] => Array ( [D4] => 5 [NB] => 2 ) ) [15] => Array ( [0] => Array ( [E1] => 3 [NB] => 1 ) [1] => Array ( [E1] => 4 [NB] => 3 ) ) I used a foreach loop: foreach($answers as $data) { //for each question print_r($data); } which gives: Array ( [0] => Array ( [A1] => 50 [NB] => 2 ) [1] => Array ( [A1] => 100 [NB] => 2 ) ) Array ( [0] => Array ( [A2] => 4 [NB] => 2 ) [1] => Array ( [A2] => 5 [NB] => 2 ) ) Array ( [0] => Array ( [A3] => 3 [NB] => 1 ) [1] => Array ( [A3] => 5 [NB] => 3 ) ) Array ( [0] => Array ( [A4] => 3 [NB] => 2 ) [1] => Array ( [A4] => 5 [NB] => 2 ) ) etc then another foreach: foreach($answers as $data) { //for each question //print_r($data); foreach($data as $value) { print_r($value); //echo '<br/><br/>'; } //new row echo '<br/>'; } which gives: Array ( [A1] => 50 [NB] => 2 ) Array ( [A1] => 100 [NB] => 2 ) Array ( [A2] => 4 [NB] => 2 ) Array ( [A2] => 5 [NB] => 2 ) Array ( [A3] => 3 [NB] => 1 ) Array ( [A3] => 5 [NB] => 3 ) etc What i need is a way to finally echo these values into tables. One for each anwer (A1, A2 etc) But I cant just do echo $value[A1], $value[NB] as the index value for the first piece of data changes for each question, e.g. A1, A2 etc Any ideas? This probably sounds very confused.
  7. Thank you, that completely sorts the problem, dont know why i didnt think of it. Thanks!
  8. Haha, you never said that (or did you?)... anyway... thats what GROUP BY is for ;-) SELECT COUNT('A1') FROM `answers` WHERE `A1` = '50' OR `A1` = '75' OR `A1` = '100' GROUP BY `A1`; Try that. Kind regards, Scott I said the number of answers of each, but i guess I wasnt very clear I tried that, but I dont think it will work as: it doesnt return empty rows for the options where answer to count = 0 and it doesnt label them. e.g.: SELECT COUNT('A1') FROM `answer` WHERE `A1` = '50' OR `A1` = '75' OR `A1` = '100' GROUP BY A1 gives: COUNT( 'A1' ) 2 2
  9. Wont that return a total number of people who answered? I need seperatly the number of people who answered 100, the number of people who answered 75 etc and thanks for tip about the *
  10. I'm not much good with php mysql queries with joins etc. Here is my problem. I have stored the results of my questionnaire in a table. The answers are multiple choice and have between 2 and 6 answers. I need a query that returns the number of answers of each and the total number of answers. I could find the number of people with each answer in a sepearate query for each answer: SELECT Count(*) FROM answers SELECT Count(*) FROM answers WHERE A1 = '100' SELECT Count(*) FROM answers WHERE A1 = '75' SELECT Count(*) FROM answers WHERE A1 = '50' SELECT Count(*) FROM answers WHERE A1 = '0' Then would need to repeat for A2, A3, B1, B2 etc each with different possible answers How could I make that into one query for each question? Any ideas?
  11. Thanks it works, just one other thing: how do I make it so the div doesnt caus the text before it and after it to go on a new line? This will send a unique link by email to: <div id="username">yourusername</div>@email.com becomes: This will send a unique link by email to: yourusername @email.com Thanks for the help Worked it out myself Changed <div> to <span> Thanks for the help
  12. Thanks, will try the code and let you know in a few minutes
  13. Thanks Is it possible without the button, ie it appearing as you type?
  14. Right, not sure if this is possible. If i asked a user to enter a username into an input box, could javascript take that username (without submiting the form) and add that username to a piece of text undernearth i.e. they enter their username and: @email.co.uk -> username@email.co.uk Thanks
  15. Thank you, I was just reading about that myself
×
×
  • 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.