Skip to content Skip to sidebar Skip to footer

Retrieving Id From Database Displayed And Passing Onto Other Page

I'm displaying the contents of a database on a particular page(recipe names). I'd like each recipe to be a link which opens to another page. I understand I would have to obtain the

Solution 1:

If you are displaying the contents of a database on a particular page, then definitely you are using a server side scripting like like ASP or PHP or some JavaScript + AJAX. I am quite unclear about that. But for your question, I can tell you one thing that, if, suppose you are using PHP, then you may display the link as;

echo'<a href="yourpage.php?recipeid='.$recepeid.'">'.$recipiename.'</a>';

where $recipeid is the variable carrying recipe id and $recipiename is the name of your recipe. In your PHP file (yourpage.php), you may catch this data like $_GET["recipeid"]

You may try a Google search for tutorials.

Use;

$strLink = '<a href="recipedisp.php?id='.$row['id'].'">'.$strName.'</a>';
echo"<li>".$strLink."</li>";

Don't use spaces.

Solution 2:

You just make the id part auf the URL the recipe link points to.

<ahref="/recipe/23">Iced Water</a>

Would be a link pointing to the recipe with ID 23. Since the url is available on the server side you are all set.

Post a Comment for "Retrieving Id From Database Displayed And Passing Onto Other Page"