Eg: Assume a user select the hyperlink of a name of a person & once click the hyperlink,user can see the details of that person.I created the dynamic part & cannot proceed further.Please help me to proceed....
hyperlink to dynamically retrieved data in a table
Moderator: General Moderators
hyperlink to dynamically retrieved data in a table
I'm new to php and i need to give an hyperlink to a data which is retrieved to a dynamically created data.Data means, table data.By that hyperlink,the user can be view the details of the selected value.
Eg: Assume a user select the hyperlink of a name of a person & once click the hyperlink,user can see the details of that person.I created the dynamic part & cannot proceed further.Please help me to proceed....
Eg: Assume a user select the hyperlink of a name of a person & once click the hyperlink,user can see the details of that person.I created the dynamic part & cannot proceed further.Please help me to proceed....
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: hyperlink to dynamically retrieved data in a table
Pass the value in a query string page.php?name=Peter. To use it, access it through $_GET['name'].
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: hyperlink to dynamically retrieved data in a table
Thanks for your support.
But that doesn't support my problem.wait i'l paste the code.
this code creates the table dynamically and retrieve data from the table.Data is retrieved by a select query.but i need to place a href to a single data to view full details of the selected one.
Hope this will understand the story to u.Cheers!!!!
But that doesn't support my problem.wait i'l paste the code.
Code: Select all
if (isset($_POST['search'])){
/*{print_r($_POST);}*/
$tx=$_POST['sea'];
$result =mysql_query("select * from strdet where styid LIKE '%$tx%' || styname LIKE '%$tx%' || odrno ='$tx' || odrdet LIKE '%$tx%' || date LIKE '%$tx%' || merch LIKE '%$tx%' || gen LIKE '%$tx%' || taxt LIKE '%$tx%' ");
//$result =mysql_query("select * from strdet where odrno ='$tx'");
if (($result)||(mysql_errno == 0))
{
echo "<table width='100%' border='0' cellspacing='5'><tr>";
if (mysql_num_rows($result)>0)
{
//loop thru the field names to print the correct headers
$i = 0;
while ($i < mysql_num_fields($result))
{
echo "<th>". mysql_field_name($result, $i) . "</th>";
$i++;
}
echo "</tr>";
//display the data
while ($rows = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<tr>";
foreach ($rows as $data)
{
echo "<td align='center'>". $data . "</td>";
}
}
}else{
echo "<td align='center'>No Results found</td></tr>";
}
echo "</table>";
}else{
echo "Error in running query :". mysql_error();
}
}
?>Hope this will understand the story to u.Cheers!!!!
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: hyperlink to dynamically retrieved data in a table
What i understand from this is : You display ALL results that matches your query. You want these values that are displayed to be a href (also now as a link or a hyperlink). So if you retrieved 'pumpkin' from the database you want something like thisishakya wrote:but i need to place a href to a single data to view full details of the selected one.
Code: Select all
<table>
<tr><th>Field</th></tr>
<tr><td><a href="page.php?value=Pumpkin" >Pumpkin</a></td></tr>
</table>
If this is what you have in mind, the code below serves as an example on how to achieve this
Code: Select all
<?php
while ($rows = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<tr>";
foreach ($rows as $data)
{
echo '<td align="center"><a href="pageName.php?value='. $data .'">'. $data .'</a>';
// this produces a link with the value of $data in the query string.
}
}
}
?>“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: hyperlink to dynamically retrieved data in a table
Thanks social_experiment,
but let me explain further,
According to the select query,user can enter different searching conditions.according to that results will be changed.So table structure is same but data is different.
Assume user enter gender as his condition,following results are displayed.
styid styname
sfsf hj
ada c
So after that if he click on sfsf,he should see the details of sfsf within the same page.Just like a pop up.Within that pop up user can update details.
But the question is,how should i do that?
foolowing section is used to print data
@where should i do?
Hope i explained which is in my mind.
Cheers again for your help!!!!!!!!!!!!!!
but let me explain further,
According to the select query,user can enter different searching conditions.according to that results will be changed.So table structure is same but data is different.
Code: Select all
$result =mysql_query("select * from strdet where styid LIKE '%$tx%' || styname LIKE '%$tx%' || odrno ='$tx' || odrdet LIKE '%$tx%' || date LIKE '%$tx%' || merch LIKE '%$tx%' || gen LIKE '%$tx%' || taxt LIKE '%$tx%' ");styid styname
sfsf hj
ada c
So after that if he click on sfsf,he should see the details of sfsf within the same page.Just like a pop up.Within that pop up user can update details.
But the question is,how should i do that?
foolowing section is used to print data
Code: Select all
if (mysql_num_rows($result)>0)
{
//loop thru the field names to print the correct headers
$i = 0;
while ($i < mysql_num_fields($result))
{
echo "<th>". mysql_field_name($result, $i) . "</th>";
$i++;
}
echo "</tr>";
//display the data
while ($rows = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<tr>";
foreach ($rows as $data)
{
echo "<td align='center'>". $data . "</td>";
}
}
}else{
echo "<td align='center'>No Results found</td></tr>";
}
echo "</table>";
}Hope i explained which is in my mind.
Cheers again for your help!!!!!!!!!!!!!!