Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8766287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:30:51+00:00 2026-06-13T16:30:51+00:00

I am creating a PHP page where the page prints out the whole of

  • 0

I am creating a PHP page where the page prints out the whole of a database I have of meat packaging. I am printing the results of the database in order of their shape (Rectangular, Oval, Square, Insert). I can happily get the database to print out the results but what I want to do for one of the columns is change the result that is printed into a HTML link.

This column is ‘Imagename’, it prints the name of a JPEG that is stored on the server. I want it so that when the result for ‘Imagename’ is printed with the JPEG on the side it isn’t text but actually a link to a new tab that displays the picture for the user to view.

Here is my current PHP that loops through the database printing it in a table:

<?php

$con = mysql_connect("localhost", "horizon1", "");
mysql_select_db("horizon1_delyn", $con);

if ( ! $con)
{
  die("Could not connect: " . mysql_error());
}

$rectangular = mysql_query("SELECT toolcode, description, traysize, imagename FROM range WHERE trayshape ='rectangular' ORDER BY traysize");
$oval        = mysql_query("SELECT toolcode, description, traysize, imagename FROM range WHERE trayshape ='oval' ORDER BY traysize");
$square      = mysql_query("SELECT toolcode, description, traysize, imagename FROM range WHERE trayshape ='square' ORDER BY traysize");
$insert      = mysql_query("SELECT toolcode, description, traysize, imagename FROM range WHERE trayshape ='insert' ORDER BY traysize");

$fields_num = mysql_num_fields($rectangular);

echo "<table width='97%' border='0' cellspacing='0' cellpadding='0'><tr>";


//*RECTANGULAR*//

for ($i = 0; $i < $fields_num; $i++)
{
  $field = mysql_fetch_field($rectangular);
  echo "<td bgcolor='#E8CF24' style='font-family: arial;font-size: 12px;'>{$field->name}</td>";
}

echo "</tr>\n";

while ($row = mysql_fetch_row($rectangular))
{
  echo "<tr>";

  foreach ($row as $cell)
    echo "<td style='font-family: arial;font-size:12px'>$cell</td>";
  echo "</tr>\n";
}
mysql_free_result($rectangular);


//* OVAL *// 

for ($i = 0; $i < $fields_num; $i++)
{
  $field = mysql_fetch_field($oval);
  echo "<td bgcolor='#E8CF24' style='font-family: arial;font-size: 12px'>{$field->name}</td>";
}

echo "</tr>\n";

while ($row = mysql_fetch_row($oval))
{
  echo "<tr>";

  foreach ($row as $cell)
    echo "<td style='font-family: arial;font-size:12px'>$cell</td>";

  echo "</tr>\n";
}
mysql_free_result($oval);


//* SQUARE *// 

for ($i = 0; $i < $fields_num; $i++)
{
  $field = mysql_fetch_field($square);
  echo "<td bgcolor='#E8CF24' style='font-family: arial;font-size: 12px'>{$field->name}</td>";
}

echo "</tr>\n";

while ($row = mysql_fetch_row($square))
{
  echo "<tr>";

  foreach ($row as $cell)
    echo "<td style='font-family: arial;font-size:12px'>$cell</td>";

  echo "</tr>\n";
}
mysql_free_result($square);


//* INSERT *// 

for ($i = 0; $i < $fields_num; $i++)
{
  $field = mysql_fetch_field($insert);
  echo "<td bgcolor='#E8CF24' style='font-family: arial;font-size: 12px'>{$field->name}</td>";
}

echo "</tr>\n";

while ($row = mysql_fetch_row($insert))
{
  echo "<tr>";

  foreach ($row as $cell)
    echo "<td style='font-family: arial;font-size:12px'>$cell</td>";

  echo "</tr>\n";
}
mysql_free_result($insert);

?>

Does anyone have any idea how I could in a sense isolate the ‘Imagename’ column to make the images clickable? Thanks for your help?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:30:52+00:00Added an answer on June 13, 2026 at 4:30 pm

    First of all, they are going to rip you to shreds for not escaping, but I’ll let someone else tell you off for that.

    At the minute you are outputting everything from the table in one go, you need to split it up, so instead of

    echo "<td style='font-family: arial; font-size: 12px;'>{$cell}</td>";
    

    You will want something like

    echo '<td style="font-family: arial;font-size:12px">' . $cell['toolcode'] . '<a href=' . $cell['imagename'] . ' target="_blank">' . $cell['imagename'] . '</a></td>';
    

    You need to echo the values individually, and then wrap an <a> tag around the hyperlink, with a href

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating pagging for some data. For example, I have a page: http://example.com/news.php?type=bla&smth=bla There
I'm currently creating a page in PHP that will display a user and their
I have a blog page on the site I'm creating (php/mysql). I generate blog
hi friends i'm creating a php page to import the data from a csv
I am creating a registration page in HTML, PHP, and MySQL. I want to
I am creating a poll script for a facebook fan page: http://www.facebook.com/apps/application.php?id=115400635147687&v=app_115400635147687 I am
I am creating a php backup script that will dump everything from a database
I've created a blog main page using PHP and have included a sidebar and
I have a Drupal module creating a page via hook_menu(). I am trying to
Drupal version 6.12 I have a page whose input format is PHP. I simply

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.