943,716 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 1601
  • PHP RSS
You are currently viewing page 1 of this multi-page discussion thread
Jun 9th, 2009
0

make link from a variable.

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Junior Poster
tulipputih is offline Offline
107 posts
since May 2009
Jun 9th, 2009
0

Re: make link from a variable.

try this
php Syntax (Toggle Plain Text)
  1. echo "<td bgcolor=#9B5DCA><a href='link_page.php?id={$lessonID'>".stripslashes(delete)."</a>
  2. </td>";
Reputation Points: 2
Solved Threads: 4
Junior Poster in Training
furqan219 is offline Offline
89 posts
since Jun 2009
Jun 9th, 2009
0

Re: make link from a variable.

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

Re: make link from a variable.

Click to Expand / Collapse  Quote originally posted by djjjozsi ...
<?php

$lessonID =2;

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

PHP Syntax (Toggle Plain Text)
  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:

PHP Syntax (Toggle Plain Text)
  1. $lesson = stripslashes($other_var);
  2. ...
Rather than mess around with the "html output".
Sponsor
Featured Poster
Reputation Points: 1048
Solved Threads: 946
Sarcastic Poster
ardav is offline Offline
6,678 posts
since Oct 2006
Jun 9th, 2009
0

Re: make link from a variable.

Thanks all, for your input..
I have tried all but none is success..the same error still appear on the same line.

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

Re: make link from a variable.

Click to Expand / Collapse  Quote originally posted by tulipputih ...
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.
Sponsor
Reputation Points: 520
Solved Threads: 268
Code Monkey
ShawnCplus is offline Offline
1,564 posts
since Apr 2005
Jun 10th, 2009
0

Re: make link from a variable.

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,

php Syntax (Toggle Plain Text)
  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.
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.

I think the problem is here

PHP Syntax (Toggle Plain Text)
  1. $myquery = "select * from lesson where subject like '%".$q."%' AND learningArea like '%".$r."%' AND ability like '%".$s."%'";

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.'%'";

Try this and let me know it is working or not?
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.

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>
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.

please use echo in start of
<td><a href='details.php?lessonID=<?php echo $lessonID; ?>'> </a></td>

this line and terminator at the end
Reputation Points: 2
Solved Threads: 4
Junior Poster in Training
furqan219 is offline Offline
89 posts
since Jun 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