By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,584 Members | 1,750 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,584 IT Pros & Developers. It's quick & easy.

how to generate hyperlink for entire column of number ID in a table

P: 34
when the result print out , i want to make hyperlink for entire column of ID. what should i do?Below was my php code.

//And we display the results
while($result = mysql_fetch_array( $data ))
{


echo "<tr><td>";
echo $result['ID'];
echo "</td><td>";
echo $result['NamaPeralatan'];
echo "</td><td>";
echo $result['Motor'];
echo "</td><td>";
echo $result['Operasi'];
echo "</td><td>";
}
Sep 23 '06 #1
Share this Question
Share on Google+
3 Replies


ronverdonk
Expert 2.5K+
P: 4,258
Don't understand your question fully. Do you want a link in the id column to where? If so, the following will do that.
[PHP]echo "<tr><td><a href='AnotherPage.php?id={$result['ID']}'>{$result['ID']}</a></td>
<td>{$result['NamaPeralatan']}</td>
<td>{$result['Motor']}</td>
<td>{$result['Operasi']}</td>
</tr>"; [/PHP]

Ronald :cool:
Sep 24 '06 #2

P: 34
Don't understand your question fully. Do you want a link in the id column to where? If so, the following will do that.
[PHP]echo "<tr><td><a href='AnotherPage.php?id={$result['ID']}'>{$result['ID']}</a></td>
<td>{$result['NamaPeralatan']}</td>
<td>{$result['Motor']}</td>
<td>{$result['Operasi']}</td>
</tr>"; [/PHP]

Ronald :cool:
yes , i was sucess to create it .thanks a lot
Sep 25 '06 #3

ronverdonk
Expert 2.5K+
P: 4,258
The AnotherPage.php looks like this:

[php]
<?php
// check if id is passed to this routine
if (isset($_GET['id']) {
// if yes: remove harmful tags and save the passed id in variable $id
$id = strip_tags($_GET['id']);
// now you can do your MySql functions (sample)
// connect to server .....
// connect to data base .....

// construct SQL statement
$sql = "SELECT field1, field2, ... from table_name WHERE ID='$id'";
// execute the select
}
else { // id not passed to this function
echo "Id was not passed to this routine";
die;
}
[/php]

Ronald :cool:
Sep 27 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.