jaiffed Posted February 21, 2010 Share Posted February 21, 2010 I have this code for grid view $query="select member_name from member where mem_id=$q && av=1"; $result= mysql_query($query,$link) or die(""); $fel=mysql_num_fields($result); $nro=mysql_num_rows($result); echo '<table border="2">'; echo "<td> Member Detail</td>"; while ($row = mysql_fetch_array($result)){ //loop through the rows echo '<tr>'; //loop through elements (ie td's) echo "<td>" . $row['member_name'] . "</td>"; } echo '</tr>'; echo '</table>'; mysql_close($link); ?> the output of this code is look like in HTML table:- .................................................. | Member detail | '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | Andy | ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | Anne | '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | Ronni | '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' but now the problem is that i want that if user click on Andy or any other name then the name of Andy come in the variable $mem_name for the next php page which will i use to show full detail of selected player what can i do to do this please help me Link to comment https://forums.phpfreaks.com/topic/192831-value-in-variable-in-grid-view-type/ Share on other sites More sharing options...
jaiffed Posted February 22, 2010 Author Share Posted February 22, 2010 I have this code for grid view $query="select member_name from member where mem_id=$q && av=1"; $result= mysql_query($query,$link) or die(""); $fel=mysql_num_fields($result); $nro=mysql_num_rows($result); echo '<table border="2">'; echo "<td> Member Detail</td>"; while ($row = mysql_fetch_array($result)){ //loop through the rows echo '<tr>'; //loop through elements (ie td's) echo "<td>" . $row['member_name'] . "</td>"; } echo '</tr>'; echo '</table>'; mysql_close($link); ?> the output of this code is look like in HTML table:- .................................................. | Member detail | '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | Andy | ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | Anne | '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' | Ronni | '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' but now the problem is that i want that if user click on Andy or any other name then the name of Andy come in the variable $mem_name for the next php page which will i use to show full detail of selected player what can i do to do this please help me Link to comment https://forums.phpfreaks.com/topic/192831-value-in-variable-in-grid-view-type/#findComment-1016296 Share on other sites More sharing options...
battlesiege Posted February 22, 2010 Share Posted February 22, 2010 well typically its bad praactise pass a value like Andy around from page to page but rather an ID. So say the a members ID is stored in a column called member_id then in your SQL query select member_id as well. Then change this line echo "<td>" . $row['member_name'] . "</td>"; to this echo '<td><a href="anotherpage.php?id=' . $row['member_id'] . '">' . $row['member_name'] . '</a></td>'; this will turn all of the member names into a link where there ID will be passed through in the URL, then on the other page you again make a query to the database to get the member name. You should probably make a function to do this query or even better a function that will deal with all user based queries (a must in any of my projects) Link to comment https://forums.phpfreaks.com/topic/192831-value-in-variable-in-grid-view-type/#findComment-1016364 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.