Jump to content


Photo

Using mysql field in a href using php echo


  • Please log in to reply
2 replies to this topic

#1 WAMFT1

WAMFT1

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 14 January 2013 - 03:12 AM

I am wanting my php page to load with content pulled from an existing mysql database. I am wanting to use multiple fields to create a href link. Can anybony help me.

Here is the script using to collect and sort data. I am wanting to replace the XXXXX with the field name doctype, batch, and branch with underscores between each field. I am not sure how to get this to work if at all.



$result=mysql_query("SELECT * FROM comm_statement WHERE paycode = 'PAYJBARR'");

while($test = mysql_fetch_array($result))
{
$id = $test['id'];
echo "<tr align='left'><font size='-2' face='Arial, Helvetica, sans-serif'>";
echo"<td>". $test['date']. "</td>";
echo"<td>" .$test['batch']."</td>";
echo"<td>" .$test['advisercode']."</td>";
echo"<td>" .$test['doctype']."</td>";
echo"<td><a href ='../../documents/advisers/DMS/XXXXX'>download</a>";

#2 Dharmender

Dharmender

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts
  • LocationDelhi, India

Posted 14 January 2013 - 03:19 AM

You can save the value of doctype in variable and use it or you can directly use it
$result=mysql_query("SELECT * FROM comm_statement WHERE paycode = 'PAYJBARR'");

while($test = mysql_fetch_array($result))
{
$id = $test['id'];
$doctype=$test['doctype'];
echo "<tr align='left'><font size='-2' face='Arial, Helvetica, sans-serif'>";
echo"<td>". $test['date']. "</td>";
echo"<td>" .$test['batch']."</td>";
echo"<td>" .$test['advisercode']."</td>";
echo"<td>" .$doctype."</td>";
echo"<td><a href ='../../documents/advisers/DMS/$doctype'>download</a>";

#3 WAMFT1

WAMFT1

    Advanced Member

  • Members
  • PipPipPip
  • 33 posts

Posted 25 February 2013 - 02:57 AM

Sorry for the delay, thanks that has helped heaps.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com