php - How do I pass the information to the other page? -
i have following code displays table 2 columns, title , year, when user clicks on title, sent page (title.php), give more information title.
echo "<table border=1> <tr> <th>title</th> <th>year</th> </tr>"; while ($record = mysql_fetch_array($mydata)) { echo "<tr>"; echo "<td><a href='title.php'>" . $record['title'] . "</a><br />" . $record['plays'] . "</td>"; echo "<td>" . $record['year'] . "</td>"; echo "</tr>"; } echo "</table>";
my question is: how pass title ($result['title']) current page title.php?
in case, you'll want pass information using variable:
echo "<table border=1> <tr> <th>title</th> <th>year</th> </tr>"; while ($record = mysql_fetch_array($mydata)) { echo "<tr>"; echo "<td><a href='title.php?title=" . $record['title'] . "'>" . $record['title'] . "</a><br />" . $record['plays'] . "</td>"; echo "<td>" . $record['year'] . "</td>"; echo "</tr>"; } echo "</table>";
although i'd suggest passing id representing primary key instead of title can grab title after db query on title.php
also, don't need mysql_fetch_array. in case, need mysql_fetch_assoc.
Comments
Post a Comment