make link from a variable.

Thread Solved

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

make link from a variable.

 
0
  #1
Jun 9th, 2009
Hi all.. really need a help. this is looks easy peasy but I can't solve it

I want to make a link from lesson ID to a details of the selected lesson ID.
<td> "<a href='details.php?lessonID=". $lessonID ."'> </a>" </td>

when I run the coding the following error appear on that line.

Parse error: parse error, expecting `','' or `';'' in C:\xampp\htdocs\lina\resultlink.php on line 65.

How the details page should be constructed so that the lessonID can be passed to it.?

many thanks for your help.
-tulip
Last edited by peter_budo; Jun 9th, 2009 at 10:25 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 64
Reputation: furqan219 has a little shameless behaviour in the past 
Solved Threads: 4
furqan219 furqan219 is offline Offline
Junior Poster in Training

Re: make link from a variable.

 
0
  #2
Jun 9th, 2009
try this
  1. echo "<td bgcolor=#9B5DCA><a href='link_page.php?id={$lessonID'>".stripslashes(delete)."</a>
  2. </td>";
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
  #3
Jun 9th, 2009
<?php

$lessonID =2;

?>
<td><a href='details.php?lessonID=<?php echo $lessonID; ?>'> </a></td>
Last edited by djjjozsi; Jun 9th, 2009 at 9:14 am.
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 982
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 128
ardav's Avatar
ardav ardav is offline Offline
Posting Shark

Re: make link from a variable.

 
0
  #4
Jun 9th, 2009
Originally Posted by djjjozsi View Post
<?php

$lessonID =2;

?>
<td><a href='details.php?lessonID=<?php echo $lessonID; ?>'> </a></td>

  1. <?php
  2. $lesson = 2;
  3. echo "<td><a href='details.php?lessonID={$lessonID}'</a></td>";
  4. ?>

If you need to stripslash/escape the value, do it beforehand:

  1. $lesson = stripslashes($other_var);
  2. ...
Rather than mess around with the "html output".
"...the woods would be a very silent place if no birds sang except for the best"
All opinions count - unless you're a serial downvoter.
F'enw i yw Mr. Blaidd. Byddwch yn ofalus - dwi'n cnoi.
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
  #5
Jun 9th, 2009
Thanks all, for your input..
I have tried all but none is success..the same error still appear on the same line.

thanks
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 1,402
Reputation: ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light ShawnCplus is a glorious beacon of light 
Solved Threads: 224
Sponsor
ShawnCplus's Avatar
ShawnCplus ShawnCplus is offline Offline
Code Monkey

Re: make link from a variable.

 
0
  #6
Jun 9th, 2009
Originally Posted by tulipputih View Post
Thanks all, for your input..
I have tried all but none is success..the same error still appear on the same line.

thanks
Then show all of the code, not just one line.
GCS d- s+ a-->? C++(++++) UL+++ P+>+++ L+++ E--- W+++
N+ o K w++(---) O? !M- V PS+>++ PE+ Y+ PGP !t- 5? X- R tv+
b+>++ DI+ D G++>+++ e+ h+>++ r y+
PMs asking for help will not be answered, post on the forums. That's what they're there for.
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
  #7
Jun 10th, 2009
ShawnCplus,
many thanks for your kind help.
this is the full code..
I have the details page ( details.php) to be linked from the selected ID).

thanks,

  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 "<tr>
  53. <td><a href='details.php?lessonID=<?php echo $lessonID; ?>'> </a></td>
  54. <td>$subject</td>
  55. <td>$learningArea</td>
  56. <td>$noofstudents</td>
  57. <td>$minutes</td>
  58. <td>$class</td>
  59. <td> $ability</td>
  60. </tr>" ;
  61. }
  62. echo "</table>";
  63.  
  64. ?>
Last edited by Ezzaral; Jun 10th, 2009 at 3:10 pm. Reason: Added [code] [/code] tags. Please use them to format any code that you post.
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
  #8
Jun 10th, 2009
I think the problem is here

  1. $myquery = "select * from lesson where subject like '%".$q."%' AND learningArea like '%".$r."%' AND ability like '%".$s."%'";

it should be:
  1. $myquery = "select * from lesson where subject like '%'.$q.'%' AND learningArea like '%'.$r.'%' AND ability like '%'.$s.'%'";

Try this and let me know it is working or not?
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
  #9
Jun 10th, 2009
Hi, I have tried the one that you suggested.
It doesn't work.
I don't have any problem to listed down the result..just to make a link to a detail page based on the lessonID chosen. Error on the same line
<td><a href='details.php?lessonID=<?php echo $lessonID; ?>'> </a></td>
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 64
Reputation: furqan219 has a little shameless behaviour in the past 
Solved Threads: 4
furqan219 furqan219 is offline Offline
Junior Poster in Training

Re: make link from a variable.

 
0
  #10
Jun 10th, 2009
please use echo in start of
<td><a href='details.php?lessonID=<?php echo $lessonID; ?>'> </a></td>

this line and terminator at the end
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