how to apply hyperlink to first element in each row of table
Posted: Thu Jan 06, 2011 11:56 pm
Hello,
I need to apply a hyperlink for all first element in each row of a table which is dynamically retrieved.
Assume:Select query returns 8 rows & 2 columns.But rows & columns will be changed according to the query.So my problem is ,i need to apply a hyperlink to data in first column.So can u help me to do that it will be very grateful.
This is my code....
bolded part will apply hyperlink to all data in retreived data...
Hope i explained everything in my mind.So please be kind enough to give a help.
Thank you.
I need to apply a hyperlink for all first element in each row of a table which is dynamically retrieved.
Assume:Select query returns 8 rows & 2 columns.But rows & columns will be changed according to the query.So my problem is ,i need to apply a hyperlink to data in first column.So can u help me to do that it will be very grateful.
This is my code....
Code: Select all
if (isset($_POST['search'])){
/*{print_r($_POST);}*/
$tx=$_POST['sea'];
//$result =mysql_query("select * from strdet where taxt ='$tx' || odrno ='$tx'");
//$query = "select field1, fieldn from table [where clause][group by clause][order by clause][limit clause]";
//$output=mysql_query("Select * from strdet
$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%' ");
if (($result)||(mysql_errno == 0))
{
echo "<table width='100%' border='0' cellspacing='1'><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"$i";
echo "</tr>";
/*$myQuery = "show columns from strdet";
$result = mysql_query($myQuery);
$row = mysql_fetch_row($result);
$columnCount = count($row);
echo"$columnCount";*/
//display the data
while ($rows = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo "<tr>";
foreach ($rows as $data)
{
[b] echo '<td align="center"><a href='. $data .'>'. $data .'</a>';[/b]
}
}
}else{
echo "<td align='center'>No Results found</td></tr>";
}
echo "</table>";
}else{
echo "Error in running query :". mysql_error();
}
}
?>bolded part will apply hyperlink to all data in retreived data...
Hope i explained everything in my mind.So please be kind enough to give a help.
Thank you.