Ok, maby I'm in way over my head here, but I never quit without trying π
Below you will see my code, but as it is today it only checks if $data2 is
set, and if it is it's displayed as a link.
But I have another table containing info on some of the companies, and I
want the script to check if the orgnum-field exists in both tables and only
then display it as a link, otherwise the companyname will be plain text.
Can anyone give me a hint ore two on how to get this done?
<?PHP
$columns = 2;
$db = mysql_connect("localhost", "user", "pass");
mysql_select_db("database",$db);
$query = "SELECT company, orgnum FROM table1 ORDER BY company";
$result = mysql_query($query);
$num_rows = mysql_num_rows($result);
$rows = ceil($num_rows / $columns);
while($row = mysql_fetch_array($result)) {
$data[] = $row['company'];
$data2[] = $row['orgnum'];
}
echo "<table>\n";
for($i = 0; $i < $rows; $i++) {
echo "<td>\n";
for($j = 0; $j < $columns; $j++) {
if(isset($data[$i + ($j * $rows)])) {
if(empty($data2[$i + ($j * $rows)])) {
echo "<td>" . ucwords(strtolower($data[$i + ($j * $rows)])) .
"</td>\n";
}else{
echo "<td><a href=\"companyinfo.php?company=" . $data2[$i +
($j * $rows)] . "\">" . ucwords(strtolower($data[$i + ($j * $rows)])) .
"</a></td>\n";
}
echo "<td width=\"5\">" . "</td>\n";
}
}
echo "</tr>\n";
}
echo "</table>\n";
?>
-Thanks-
JΓΈrn