Advertisement
Guest User

Untitled

a guest
Jul 8th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. <?php
  2. $servername = "127.0.0.1";
  3. $username = "dylan326";
  4. $password = "";
  5. $dbname = "questions87";
  6. $port = 3306;
  7.  
  8.  
  9. $conn = mysqli_connect($servername, $username, $password, $dbname,
  10. $port);
  11.  
  12. if (!$conn) {
  13. die("Connection failed: " . mysqli_connect_error());
  14. }
  15. echo "<a href='index.html'> Log out </a><br>
  16. <a href='ask.php'> Ask a question</a><br>
  17. <br />
  18. <br />";
  19.  
  20. echo "Answer another users question: <br><br />";
  21.  
  22. $sql = "SELECT q_id,question, username FROM questions";
  23.  
  24. $result = mysqli_query($conn, $sql);
  25.  
  26. if (mysqli_num_rows($result) > 0) {
  27.  
  28. while($row = mysqli_fetch_array($result))
  29. {
  30.  
  31. $q_id = $row['q_id'];
  32. $question = $row['question'];
  33. $username = $row['username'];
  34.  
  35. //right here I need to add(concat) the second variable $username to
  36. //these links forthe next page but nothing I have tried has worked
  37.  
  38. echo ('<a href="totalqs.php?q_id=' . $q_id .' " >' . $question .
  39. '</a>' . '<br>');
  40. }
  41. } else {
  42. echo "0 results";
  43. }
  44.  
  45. mysqli_close($conn);
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement