0

Hello my data base have various columns , in a mysql fetch I am listing only the title column, but I would like that list to make a link on the already listd result which link will open a new page with the same result but this time listing all the columns from the table on this row.

mt SQL fethc is:

 (!$result = mysqli_query($con,"SELECT * FROM tablename WHERE type = 'Panes'"))

and my sql result is: <?php echo $row['name']; ?> -> which result I would like to be link.

I wold like to know if somebody have any suggestion for a possible resolution. Thanks!

Vladimir Vasilev
  • 19
  • 1
  • 1
  • 6
  • I would use a POST/GET variable to pass the info along and update your actual query to pass that value into a prepared statement as a parameter. have you actually tried anything yourself though – Fluffeh Sep 26 '13 at 01:22
  • [Not sure if I understood why you're trying to say, but I believe what you want is to be able to use * and have the result associative using prepared statement with mysqli, see this?](http://stackoverflow.com/a/18502088/342740) – Prix Sep 26 '13 at 01:26
  • My result from tablemname now is the name row, I want this result to be shown with a link which link points to mysql result which will show the information from all the columns of this row which is displaying – Vladimir Vasilev Sep 26 '13 at 01:33

3 Answers3

0

Try echoing an anchor tag. <a href="my_link">$row['name']</a>

Barmar
  • 741,623
  • 53
  • 500
  • 612
Vulcronos
  • 3,428
  • 3
  • 16
  • 24
0

Use something like this:

<a href="display_item?id=<?php echo $row['id']; ?>"><?php echo $row['name']; ?></a>

The display_item.php script then displays the row with the ID in $_GET['id'].

Barmar
  • 741,623
  • 53
  • 500
  • 612
0

You cannot do that if you want to have a single query in your code(base from your query). You must do another query for the click item or link..

If you do not need all the columns in your table to not use * instead select only what you need to make your code more readable and to be faster to execute.

Revised your string query,

"SELECT id, name FROM tablename WHERE type = 'Panes'"

and in your code to display the result to make a link,

<a href = "displayAllColumns.php?id=<?php echo $row['id']; ?>"><?php echo $row['name']; ?></a>

And in your page displayAllColumns.php you must get the passed data through get method

$id = $_POST['id'];
//then make a query for that to select all the data on that id
//just have to type only the string so
"SELECT * FROM tablename WHERE id = '$id'"
//you must use `*` because you need to display all the columns then write your table code to display the result.

Hope it helps

HTTP
  • 1,674
  • 3
  • 17
  • 22