943,895 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1602
  • PHP RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jun 10th, 2009
0

Re: make link from a variable.

php Syntax (Toggle Plain Text)
  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>" ;
Reputation Points: 12
Solved Threads: 11
Junior Poster in Training
djjjozsi is offline Offline
69 posts
since Jun 2009
Jun 10th, 2009
0

Re: make link from a variable.

this is a typo error in your SQL query then
Click to Expand / Collapse  Quote originally posted by navi17 ...
..........
it should be:
PHP Syntax (Toggle Plain Text)
  1. $myquery = "select * from lesson where subject like '%'.$q.'%' AND learningArea like '%'.$r.'%' AND ability like '%'.$s.'%'";
........
and,
the SQL save version is this:
php Syntax (Toggle Plain Text)
  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}%'";
Reputation Points: 12
Solved Threads: 11
Junior Poster in Training
djjjozsi is offline Offline
69 posts
since Jun 2009
Jun 10th, 2009
0

Re: make link from a variable.

try this:

PHP Syntax (Toggle Plain Text)
  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.
Reputation Points: 15
Solved Threads: 6
Junior Poster
navi17 is offline Offline
118 posts
since Oct 2007
Jun 10th, 2009
0

Re: make link from a variable.

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.
Reputation Points: 12
Solved Threads: 11
Junior Poster in Training
djjjozsi is offline Offline
69 posts
since Jun 2009
Jun 10th, 2009
1

Re: make link from a variable.

it will print the data from the database.
i am sure.
Reputation Points: 15
Solved Threads: 6
Junior Poster
navi17 is offline Offline
118 posts
since Oct 2007
Jun 10th, 2009
1

Re: make link from a variable.

Click to Expand / Collapse  Quote originally posted by navi17 ...
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.
Reputation Points: 12
Solved Threads: 11
Junior Poster in Training
djjjozsi is offline Offline
69 posts
since Jun 2009
Jun 10th, 2009
0

Re: make link from a variable.

I have tried that as well..
please anyone who can identify the error...

thanks.
Reputation Points: 10
Solved Threads: 0
Junior Poster
tulipputih is offline Offline
107 posts
since May 2009
Jun 10th, 2009
0

Re: make link from a variable.

Click to Expand / Collapse  Quote originally posted by navi17 ...
try this:

PHP Syntax (Toggle Plain Text)
  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
Reputation Points: 10
Solved Threads: 0
Junior Poster
tulipputih is offline Offline
107 posts
since May 2009
Jun 10th, 2009
0

Re: make link from a variable.

Click to Expand / Collapse  Quote originally posted by djjjozsi ...
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
Reputation Points: 10
Solved Threads: 0
Junior Poster
tulipputih is offline Offline
107 posts
since May 2009
Jun 10th, 2009
0

Re: make link from a variable.

Thanks all for your help..
NAvi17 & djjjozsi i have corrected it now..
credits for both of you
It works perfectly now.
Reputation Points: 10
Solved Threads: 0
Junior Poster
tulipputih is offline Offline
107 posts
since May 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Internationalization - MySQL queries
Next Thread in PHP Forum Timeline: cake php





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC