dynamic link

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mushfiq
    New Member
    • Nov 2008
    • 5

    dynamic link

    hi all.i have faced a problem.


    input used:

    i have a mysql database named form.there is a table named dynamic.

    three attributes here

    id ( primary key,auto increment)
    name.
    company.


    Expected result:

    i want to show the data of the name field and make them a link to go to another page as like as:

    mushfiq
    mishuk

    the two above name will used to go to the page "dynamic2.p hp" .As for example ,if i click on mushfiq,the url will be "dynamic2.p hp" & in that show the company where mushfiq works.but

    mushfiq
    mishuk

    is not showed by ..

    error codes:

    Parse error: syntax error, unexpected $end in c:\wamp\www\dyn amic.php on line 33


    Code:
     <!DOCTYPE html PUBLIC
         "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     <html>
     <head>
     <title>
     </title>
     </head>
     <body>
      <?php
           mysql_connect("localhost", "root", "");
       mysql_select_db("form");
    	  $result=mysql_query("select name from dynamic") or  die(mysql_error()); 
    	  
    	  if(mysql_num_rows($result)==0)
    	   {
    	    echo "database is empty <br>";
    	   }  else 
    	    {
    		 while(list($id,$name)=mysql_fetch_array($result))
    		  {
    		?>
     <a href="dynamic2.php?id=<?php $id ?>"> <?php echo $name; ?>  </a> <br >
    		
    		<?php
    		} 
    		
    ?>
     </body>
     </html>
    may be problem is in that line:

    <a href="dynamic2. php?id=<?php $id ?>"> <?php echo $name; ?> </a> <br >


    but i m not sure.if anyone can help me, i will be greatful.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Mushfiq, this is an official warning: use code tags when posting code in the forums. Failure to adhere to the Forum Guidelines will result in a ban.

    Comment

    • Markus
      Recognized Expert Expert
      • Jun 2007
      • 6092

      #3
      The error you receive is because you are missing a closing brace for your else statement.

      Comment

      • mushfiq
        New Member
        • Nov 2008
        • 5

        #4
        i cant understand.did i not use code tag?

        Comment

        • NeoPa
          Recognized Expert Moderator MVP
          • Oct 2006
          • 32636

          #5
          I'm afraid not. They were added later by Markus, a moderator of this forum.

          PS. Notice that he has also submitted an answer to your question. This is much easier to see if the code is posted clearly as suggested.

          Comment

          Working...