Differences

This shows you the differences between two versions of the page.

Link to this comparison view

new-turn [2018-03-23 10:41]
Joakim Forsgren
new-turn [2022-07-18 13:20]
Line 1: Line 1:
-====== e=new-turn ====== 
-Vi har bestämt att vi ska spara alla frågor som hör till ett game som en serialized array 
-<code php> 
-// Struktur på $game_questions. 
- 
-$game_questions = [ 
-  0 => 31, 
-  1 => 17, 
-  2 => 8, 
-]; 
- 
-serialize($game_questions) 
-</code> 
- 
-Utöver detta nedan måste man göra vissa kollar, typ att det inte redan finns 18 frågor mm 
- 
-1. Hämta ut game och hämta ut de frågor som finns 
- 
-<code php> 
-query = "SELECT * FROM `games` WHERE `id` = '" . $_POST['game_id'] . "'"; 
-$result = query($query); 
-$game = mysqli_fetch_assoc($result); 
-$game_questions = unserialize($game['questions']); 
-</code> 
- 
- 
-2. Slumpla fram 3 nya frågor och lägg till dessa till $game_questions 
-<code php> 
- 
-while ($row = mysqli_fetch_assoc($result)) { 
-  $game_questions[] = $row['id']; 
-} 
-</code> 
-3. Uppdatera game med de nya antalet frågor