2

here is the code i am using for displaying my table ..

   $hfeed ="SELECT title, author , description ,price FROM items"; 
   $resfeed = $conn4->query($hfeed);
   echo   "<table>" ;
   echo "<tr><th>Title</th><th>Author</th><th>Price</th></tr>";
   if ($resfeed->num_rows > 0) 
   {
   while($row = $resfeed->fetch_assoc()) 
   {
   echo "<tr> <td><a href='content.php'>". $row["title"]. "</a></td> <td>". $row["author"]. "</td> <td>" . $row["price"]. "</td> </tr>";
   }
   }
   else
   {
   echo "0 results";
   }
   echo "</table>";

what should i code for content.php to display the fields of a desired cell.

2 Answers 2

1

use $_GET in a tag:

<a href='content.php?author=".$row["author"]."&title=".$row["title"]."'>".$row["title"]."</a>

and in content.php file you handle the $_GET variables as such:

if(isset($_GET["author"])) { $author = $_GET["author"]; }
if(isset($_GET["title"])) { $title = $_GET["title"]; }

if(($author) && ($title)) {
    $sql = "SELECT column1,column2,columnN FROM items WHERE author=".$author." AND title=".$title;
    ..
    // do mysql query
    // show results.
}
Sign up to request clarification or add additional context in comments.

3 Comments

its working ...but only for the first 2 items...here is the content.php if(isset($_GET["author"])) { $author = $_GET["author"]; } if(isset($_GET["title"])) { $title = $_GET["title"]; } if(isset($_GET["description"])) { $description = $_GET["description"]; } if(($author) && ($title) && ($description)) { $cfeed ="SELECT title, author,description FROM items WHERE title='$title' AND author='$author' AND description='$description'"; $rescfeed = $conn5->query($cfeed); if ($rescfeed->num_rows > 0) { echo $author; } }
it worked ...there was a problem with a database ..but that was taken care of..Thanx very much
@ronit Well, alright. Accept the answer if it helped you, so others can see aswell.
0

try passing the values as parameters. maybe in a json format ? its up to you

Encode the row

json_encode($row)

href='content.php?parameters='.$row

then content.php should decode the parameters and u can use them.

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.