Jump to content

value in variable in grid view type


jaiffed

Recommended Posts

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

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

 

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)

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.