0

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.

4
Contributors
4
Replies
6
Views
7 Years
Discussion Span
Last Post by vaultdweller123
1

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>');
?>

0

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

0

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

Edited by happygeek: fixed formatting

0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.