Hello all,

<?php
$result = mysql_query("SELECT Artikelnummer, Artikelmerk, Artikelnaam FROM Product ORDER BY Artikelnummer;");
printf('<table class="adminblok">');
while($r = mysql_fetch_assoc($result))
{

printf("<tr><td><a href="#">%u</a></td><td></td><td>%s</td><td>%s</td></tr>",$r[ "Artikelnummer"], $r["Artikelmerk"], $r["Artikelnaam"]);

}
printf('</table>');
?>

The codes that are printed bold are the tags that don't work on my website! Why is this and how can i fix this?
I want to show a list out of the database and also make it links. So when I click on an attribute, it shows a new page with all attributes from that record.

1. You can not write double quotes (") inside a double quote.

Correct code is...

printf("<tr><td><a href=\"#\">%u</a></td><td></td><td>%s</td><td>%s</td></tr>",$r[ "Artikelnummer"], $r["Artikelmerk"], $r["Artikelnaam"]);


OR


printf("<tr><td><a href='#'>%u</a></td><td></td><td>%s</td><td>%s</td></tr>",$r[ "Artikelnummer"], $r["Artikelmerk"], $r["Artikelnaam"]);


2. To make link and display corresponding data just write code as ...

<?php
$result = mysql_query("SELECT url,Artikelnummer, Artikelmerk, Artikelnaam FROM Product ORDER BY Artikelnummer;");
printf('<table class="adminblok">');
while($r = mysql_fetch_assoc($result))
{

printf("<tr><td><a href=\"%s\">%u</a></td><td></td><td>%s</td><td>%s</td></tr>",$r[ "url"],$r[ "Artikelnummer"], $r["Artikelmerk"], $r["Artikelnaam"]);

}
printf('</table>');
?>

It works! Thank you very much for your help!
I did it with <a href='#'>%u</a>

mark it solved, and give theMan, Manish, an attaboy :)

Lafreak,
this problem would be apparent if you got yourself a code highlighting editor
notepad++ nodepad2, any of hundreds of notepad replacements or ide-s

Wrapped in code tags to enable code highlighting on this page your code looks like this

$result = mysql_query("SELECT Artikelnummer, Artikelmerk, Artikelnaam FROM Product ORDER BY Artikelnummer;");
printf('<table class="adminblok">');
while($r = mysql_fetch_assoc($result))
{

printf("<tr><td><a href="#">%u</a></td><td></td><td>%s</td><td>%s</td></tr>",$r[ "Artikelnummer"], $r["Artikelmerk"], $r["Artikelnaam"]);

}
printf('</table>');
?>

and its easy to see something wrong in line 7
a code highlighting editor does the same with your local files while you work
not meant as a solution to this question, but it may save a lot of debugging later

yezzz manish and almostbob are correct. i recommend you use notepad++ as your editor, beside the coloring capability, notepad++ detects the start and ending tags and braces/blocks which is very cool and helpful.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.