Guest User

Untitled

a guest
Jun 21st, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. $digits = array(9,8,7,6,5,4,3,2,1);
  2. $primes = array(2,3,5,7,11);
  3.  
  4. for ($first = 0; $first < count($digits)-1; $first++) {
  5. $num1 = $digits[$first];
  6. for ($second = 1; $second < count($digits)-2; $second++) {
  7. $num2 = $digits[$second];
  8. for ($third = 0; $third < count($primes)-1; $third++) {
  9. $num3 = $num1 * $primes[$third];
  10. $num4 = $num2 * $primes[$third];
  11.  
  12. $questionlead = "Simplify <br>" .$num3. " : " . $num4 ;
  13. $ans = $num1. " : " . $num2 ;
  14.  
  15. $dbhost = 'nope';
  16. $dbuser = 'notfor';
  17. $dbpass = 'you';
  18.  
  19. $conn = mysql_connect($dbhost, $dbuser, $dbpass);
  20.  
  21. if(! $conn ) {
  22. die('Could not connect: ' . mysql_error());
  23. }
  24.  
  25. $sql = "INSERT INTO QuestionDB(TopicID, TopicName, SubtopicID, SubtopicName, Question, Answer, Difficulty, Author, Projectable) VALUES (6,'Ratio',1,'Simplifying ratio','".$questionlead. "','".$ans. "',1,'Richard Tock','Yes')";
  26. mysql_select_db('db_name');
  27. $retval = mysql_query( $sql, $conn );
  28.  
  29. if(! $retval ) {
  30. die('Could not get data: ' . mysql_error());
  31. }
  32.  
  33. }
  34. }
  35. }
  36. mysql_close($conn);
  37. ?>
Add Comment
Please, Sign In to add comment