Ok, first off let me thank anyone taking the time to read my post. I really appreciate taking the time to see if you can help this ‘noob’. Also, I apologize if I posted this too many time, but I couldn’t determine if this was a true php question, or more of a database question, so I posted it in both threads.
I am not super new to any form of coding, but I am a master at none of them. Here is what I am doing.
I have a table in a MySQL(ver 5.5) and I have an e107 site which runs on the PHP Version 5.3.6 system. I have created a php application using NetBean that basically queries the table and returns the results in a nested table created by the php function(see code below).
[php]<?php
function SQLResultTable($Query)
{
$link = mysql_connect(localhost, UN, PW) or die('Could not connect: ’ . mysql_error()); //build MySQL Link
mysql_select_db(my_db) or die(‘Could not select database’); //select database
$Table = “”; //initialize table variable
$Table.= "<table border='2' style=\"border-collapse: collapse;\">"; //Open HTML Table
$Result = mysql_query($Query); //Execute the query
if(mysql_error())
{
$Table.= "<tr><td>MySQL ERROR: " . mysql_error() . "</td></tr>";
}
else
{
//Header Row with Field Names
$NumFields = mysql_num_fields($Result);
$Table.= "<tr style=\"background-color: #000066; color: #FFFFFF;\">";
for ($i=0; $i < $NumFields; $i++)
{
$Table.= "<th>" . mysql_field_name($Result, $i) . "</th>";
}
$Table.= "</tr>";
//Loop thru results
$RowCt = 0; //Row Counter
while($Row = mysql_fetch_assoc($Result))
{
//Alternate colors for rows
if($RowCt++ % 2 == 0) $Style = "background-color: #E7E7E7;";
else $Style = "background-color: #8C9EC1;";
$Table.= "<tr style=\"$Style\">";
//Loop thru each field
foreach($Row as $field => $value)
{
$Table.= "<td>$value</td>";
}
$Table.= "</tr>";
}
$Table.= "<tr style=\"background-color: #000066; color: #FFFFFF;\"><td colspan='$NumFields'>Query Returned " . mysql_num_rows($Result) . " records</td></tr>";
}
$Table.= "</table>";
return $Table;
}
//I call the function like this so it refreshes with new data everytime the page refreshes:
echo SQLResultTable(“SELECT Full_Name,Dept,Title,Phone,Image FROM e107_directory ORDER BY Full_Name asc”);
?>[/php]
The table returns just fine, however I want to add another column to that table. There is a field not displayed in the table currently that is present in my database that has a unique text string for each table entry of “employee_id.jpg”.
I want to have a 5th column in my table (last column) that adds a text string of ‘pic’ that would then be an href to \server\folder\employee_id.jpg so if you clicked on it and there was a file you would get an image of the person in a popup.
I assume the link can be assembled using concatenation of some form or another. I could also make the SQL table entry for ‘image’ hold the entire path if need be. My problem is I have no idea how to do this, or even if this is possible.
Can anyone point me in the right direction please? I would be forever grateful!