<?php
$db = mysql_connect("localhost", "test", "test");
mysql_select_db("test");
// yada yada ..code ...
echo ("<p><a href='" . $item_link . "' target='_blank'>" . $item_title . "</a>");
$sql = mysql_query("insert into myTable(item_link , item_title ,) values('$item_link ', '$item_title ')");
mysql_close($db);
?>
Asked
Active
Viewed 25 times
0

Alive to die - Anant
- 70,531
- 10
- 51
- 98

user315819
- 29
- 5
-
your echo is outputting the values of `$item_link` and `$item_title` to the page. they'll insert that data just fine if you assigned them values somewhere in your `// yada yada ..code ...` code section (while ignoring your non paramatized array) – Memor-X Aug 15 '16 at 05:02
-
1first don't use deprecated and removed `mysql_*` library. turn to `mysqli_*` or `PDO`. Also it's unclear what you really want to achieve – Alive to die - Anant Aug 15 '16 at 05:03
-
No, they have values. the each is print out a link and I want that link to trigger the insert. How do I get code that into the link – user315819 Aug 15 '16 at 05:04
-
Your question looks incomplete. Post what you need exact. Use mysqli_* as suggested by @Anant – Naresh Kumar P Aug 15 '16 at 05:04
-
I just want that link that gets echoed to trigger the insert. Im not sure i wrote it right. – user315819 Aug 15 '16 at 05:05
-
After link click if you want to trigger insert then:- 1. create a new page which your link have, like suppose your link is `` then create abc.php and write the insert query there.2 Or on the link click just use ajax to send link and title to a php page and do the insert code there (then your link page will not refreshed) – Alive to die - Anant Aug 15 '16 at 05:07
-
If the link is in the same page you could write using the $_REQUEST for inserting into the DB . if it points to another page you can't write it in this page to insert. – Naresh Kumar P Aug 15 '16 at 05:09
-
in that case on the page you link to you either put in some code that gets the [current url](http://stackoverflow.com/q/6768793/1028804) and run your query on that page or you use javascript to ajax to a php file sending the url to it and having it insert before you move off the page – Memor-X Aug 15 '16 at 05:09