0

this is my updated link:

<a href="Portfolio.php?val="'.$row['profile_name'].'" id="link">

and this is my updated SQL query

"SELECT * 
 FROM profile 
 WHERE profile_type = value=".$_REQUEST['val'].""; 

at the moment this is bringing back nothing does this code look correct or do i need to alter it in anyway ??

any help would be much appreciated.

5
  • Why don't you append the id on the href like Portfolio.php?id=1 and then you can use $_GET['id'] to read it back when that page is loaded. And make sure to properly sanitize it before using on the SQL query. Commented Apr 9, 2014 at 9:13
  • because at the moment there are about 20 of these links on one page and they are being being brought from a database the href="" that is within the link wont actually be used @Prix Commented Apr 9, 2014 at 9:15
  • You can set links dynamic as well ... Commented Apr 9, 2014 at 9:17
  • 2
    value is not valid as attribute for the <a> tag. Commented Apr 9, 2014 at 9:20
  • @RolandJansen then how would you do this ?? Commented Apr 9, 2014 at 9:23

3 Answers 3

1

Try this:

Pass that value in query string

<a href="Portfolio.php?val=".<?php echo $row['field']; ?>." " id="link"> </a>

Use it in query like:

 "SELECT * 
 FROM profile 
 WHERE profile_type = ".$_REQUEST['val']." "; 
Sign up to request clarification or add additional context in comments.

7 Comments

would this work if i used <a href="portfolio.php?val='.$row["value"].'" @Anandsolanki
Yes just change your syntax like <a href="portfolio.php?val='.<?php echo $row["value"]; ?>.'"
would this not be <a href="portfolio.php?val='.<?php echo $row["value"]; ?>.'">; because you only have one closing bracket and two opening
@Arnandsolanki I have altered my code but it will not bring back any results any ideas i will alter my code above to what i have got
Try this query my friend, it will surely works: "SELECT * FROM profile WHERE profile_type = ".$_REQUEST['val']." ";
|
0

As it has been pointed out - value is not a attribute for an anchor tag.

You need to update the anchor tag href attribute to be something like

<a href="Portfolio.php?value=1" id="link">Click Here</a>

This will send the value to the php side when clicked. Which can then be retrieved by the php side using the $_GET array.

<?php
if (isset($_GET['value']))
{  // Check that the value was passed
   $val = $_GET['value'];

   // TODO: Use val in SQL as required.
}
?>

3 Comments

how would i alter this with the example above ??
@user3387522 You need a good grasp of what you are trying to achieve in order to understand the question and answers being posted here. Please read up some tutorials/guides on how to update sql data, try starting at - wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers.
@user3387522 Your code sample is lacking details, and clearly, anything I post here will not work as it lacks those details.
0

You don't need to use the value = part. the query should be

"SELECT * FROM profile WHERE profile_type = ".$_REQUEST['val']." ";

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.