...

View Full Version : Variable in href in table



Sapient
07-10-2007, 06:01 PM
I would like each field in a table (generated from an Oracle database) to be a link to a different page. For example, all rows in field one would link to "linkone.php", all rows from field 2 would link to "linktwo.php, and all rows from field three would link to "linkthree.php".

I think the best way to do this is to use a $VARIABLE, based on $i as in the code below. But I can't figure out the syntax for placing a variable in my href.


// Read fetched data.
while (oci_fetch($s))
{
// Print open and close HTML row tags and columns data.
print '<tr>';
for ($i = 1;$i <= oci_num_fields($s);$i++)
print '<td class="v"><a href=\'$VARIABLE.php?dataset='.oci_result($s,$i).'\'>'.oci_result($s,$i).'</td>';
print '</tr>';
}

Any help would be greatly appreciated.

_Aerospace_Eng_
07-10-2007, 06:19 PM
Because you are using single quotes on your print statement you need to concatenate your variable which you seem to have done for your other variables. Try this

// Read fetched data.
while (oci_fetch($s))
{
// Print open and close HTML row tags and columns data.
print '<tr>';
for ($i = 1;$i <= oci_num_fields($s);$i++)
print '<td class="v"><a href="'.$VARIABLE.'.php?dataset='.oci_result($s,$i).'">'.oci_result($s,$i).'</td>';
print '</tr>';
}

Sapient
07-10-2007, 06:23 PM
Thanks much!



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum