make link from a variable.

Thread Solved

Join Date: Jun 2009
Posts: 68
Reputation: djjjozsi is an unknown quantity at this point 
Solved Threads: 10
djjjozsi djjjozsi is offline Offline
Junior Poster in Training

Re: make link from a variable.

 
0
  #21
Jun 10th, 2009
you can print the $lessonID after the Datails word...

I don't like saying this but my version still created the same output like navi17's example,

decide which is shorten or which comes earier

  1. echo "<tr>
  2. <td><a href='details.php?lessonID=$lessonID'>Details for $subject( $lessonID )</a></td>
  3. <td>$subject</td>
  4. <td>$learningArea</td>
  5. <td>$noofstudents</td>
  6. <td>$minutes</td>
  7. <td>$class</td>
  8. <td> $ability</td>
  9. </tr>" ;
Reply With Quote Quick reply to this message  
Join Date: Apr 2009
Posts: 340
Reputation: Josh Connerty is an unknown quantity at this point 
Solved Threads: 26
Josh Connerty's Avatar
Josh Connerty Josh Connerty is offline Offline
Posting Whiz

Re: make link from a variable.

 
0
  #22
Jun 11th, 2009
  1. <?php
  2.  
  3. mysql_connect("localhost","root","");
  4.  
  5. mysql_select_db("student") or die("Unable to select database");
  6. ?>
  7.  
  8. <form name="form" action="result.php" method="get">
  9.  
  10. Subject <input type="text" name="q" />
  11. Topic <input type="text" name="r" />
  12. Ability <input type="text" name="s" />
  13.  
  14. <input type="submit" name="Submit" value="Search" />
  15. </form>
  16.  
  17. <?php
  18. // Get the search variable from URL
  19. $q = $_GET['q'] ;
  20.  
  21. $r = $_GET['r'] ;
  22.  
  23. $s = $_GET['s'] ;
  24.  
  25. // Build SQL Query
  26. $myquery = "select * from lesson where subject like '%".$q."%' AND learningArea like '%".$r."%' AND ability like '%".$s."%'";
  27. //echo $myquery ;
  28. $result = mysql_query ($myquery);
  29.  
  30.  
  31. echo "<table>" ;
  32. echo "<tr><th>Lesson ID</th>";
  33. echo "<th>Subject</th>";
  34. echo "<th>Learning Area</th>";
  35. echo "<th>No of Students</th>";
  36. echo "<th>Time Period</th>";
  37. echo "<th>Class</th>";
  38. echo "<th>Ability</th></tr>";
  39.  
  40. while ($row= mysql_fetch_array($result))
  41. {
  42. $lessonID = $row["lessonID"];
  43. $subject = $row["subject"];
  44. $learningArea= $row["learningArea"];
  45. $noofstudent= $row["noofstudents"];
  46. $minutes= $row["minutes"];
  47. $class= $row["class"];
  48. $ability= $row["ability"];
  49.  
  50. //display the row
  51.  
  52. echo <<<EOD
  53. <tr>
  54. <td><a href="details.php?lessonID=$lessonID"> </a></td>
  55. <td>$subject</td>
  56. <td>$learningArea</td>
  57. <td>$noofstudents</td>
  58. <td>$minutes</td>
  59. <td>$class</td>
  60. <td> $ability</td>
  61. </tr>
  62. EOD;
  63. }
  64. echo "</table>";
  65.  
  66. ?>
Last edited by Josh Connerty; Jun 11th, 2009 at 1:10 am.
Posts should be like mini-skirts, long enough to cover enough, but not too long that you cover too much.

My Liveperson: http://liveperson.com/josh-connerty/
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 78
Reputation: navi17 is an unknown quantity at this point 
Solved Threads: 5
navi17 navi17 is offline Offline
Junior Poster in Training

Re: make link from a variable.

 
0
  #23
Jun 11th, 2009
tulipputih if your problem is solved then mark this forum as solved.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:




Views: 1036 | Replies: 22
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC