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
  #11
Jun 10th, 2009
  1. echo "<tr>
  2. <td><a href='details.php?lessonID=$lessonID'>Details</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: 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
  #12
Jun 10th, 2009
this is a typo error in your SQL query then
Originally Posted by navi17 View Post
..........
it should be:
  1. $myquery = "select * from lesson where subject like '%'.$q.'%' AND learningArea like '%'.$r.'%' AND ability like '%'.$s.'%'";
........
and,
the SQL save version is this:
  1. $q = isset($_GET['q'])? mysql_real_escape_string($_GET['q']):'';
  2. $r = isset($_GET['r'])? mysql_real_escape_string($_GET['r']):'';
  3. $s = isset($_GET['s'])? mysql_real_escape_string($_GET['s']):'';
  4.  
  5. // Build SQL Query
  6. $myquery = "select * from lesson where subject like '%{$q}%' AND learningArea like '%{$r}%'
  7. AND ability like '%{$s}%'";
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
  #13
Jun 10th, 2009
try this:

  1. while ($row= mysql_fetch_array($result))
  2. {
  3. $lessonID = $row["lessonID"];
  4. $subject = $row["subject"];
  5. $learningArea= $row["learningArea"];
  6. $noofstudent= $row["noofstudents"];
  7. $minutes= $row["minutes"];
  8. $class= $row["class"];
  9. $ability= $row["ability"];
  10.  
  11. ?>
  12. //display the row
  13.  
  14. <tr>
  15. <td><a href="details.php?lessonID=<?php echo $lessonID; ?>"> Details</a></td>
  16. <td><?php echo $subject; ?></td>
  17. <td><?php echo $learningArea; ?></td>
  18. <td><?php echo $noofstudents; ?></td>
  19. <td><?php echo $minutes; ?></td>
  20. <td><?php echo $class; ?></td>
  21. <td><?php echo $ability; ?> </td>
  22. </tr>
  23. <?php } ?>
  24. </table>

i am sure it works.
Last edited by navi17; Jun 10th, 2009 at 9:18 am.
Reply With Quote Quick reply to this message  
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
  #14
Jun 10th, 2009
but its not printing the data from the database... you will see $minutes and other stuffs in the output...
.....
the shortest is the better...
Last edited by djjjozsi; Jun 10th, 2009 at 9:24 am.
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.

 
1
  #15
Jun 10th, 2009
it will print the data from the database.
i am sure.
Reply With Quote Quick reply to this message  
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.

 
1
  #16
Jun 10th, 2009
Originally Posted by navi17 View Post
it will print the data from the database.
i am sure.
i've seen your first version, and in that post i did not see the <?php echo $field... ; ?>
which needed to print the values.

if i saw it wrong then sorry about it.
Last edited by djjjozsi; Jun 10th, 2009 at 9:36 am.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: make link from a variable.

 
0
  #17
Jun 10th, 2009
I have tried that as well..
please anyone who can identify the error...

thanks.
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: make link from a variable.

 
0
  #18
Jun 10th, 2009
Originally Posted by navi17 View Post
try this:

  1. while ($row= mysql_fetch_array($result))
  2. {
  3. $lessonID = $row["lessonID"];
  4. $subject = $row["subject"];
  5. $learningArea= $row["learningArea"];
  6. $noofstudent= $row["noofstudents"];
  7. $minutes= $row["minutes"];
  8. $class= $row["class"];
  9. $ability= $row["ability"];
  10.  
  11. ?>
  12. //display the row
  13.  
  14. <tr>
  15. <td><a href="details.php?lessonID=<?php echo $lessonID; ?>"> Details</a></td>
  16. <td><?php echo $subject; ?></td>
  17. <td><?php echo $learningArea; ?></td>
  18. <td><?php echo $noofstudents; ?></td>
  19. <td><?php echo $minutes; ?></td>
  20. <td><?php echo $class; ?></td>
  21. <td><?php echo $ability; ?> </td>
  22. </tr>
  23. <?php } ?>
  24. </table>

i am sure it works.

Hi Navi17.
thanks a lot..can be linked to details page.
however, the Id number is not shown in the result..
all show the same string..details..but the lesson Id that sent to details page is correct (the lessonID)
just the Id is not displayed in the table.
any idea to correct it?

thanks
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: make link from a variable.

 
0
  #19
Jun 10th, 2009
Originally Posted by djjjozsi View Post
i've seen your first version, and in that post i did not see the <?php echo $field... ; ?>
which needed to print the values.

if i saw it wrong then sorry about it.
djjjozsi, it does work for me..I mean the link.
the code that I posted before also print data from the database..
The problem is to make a link to the details page.
now, Navi17 has solved that problem..however the ID is not printed here..but the value is passed to the details page... I need both..the lessonID printed & the value passed.
ANy solution. Mny thanks for your respond
Reply With Quote Quick reply to this message  
Join Date: May 2009
Posts: 81
Reputation: tulipputih is an unknown quantity at this point 
Solved Threads: 0
tulipputih tulipputih is offline Offline
Junior Poster in Training

Re: make link from a variable.

 
0
  #20
Jun 10th, 2009
Thanks all for your help..
NAvi17 & djjjozsi i have corrected it now..
credits for both of you
It works perfectly now.
Reply With Quote Quick reply to this message  
Reply

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


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC