webguy Posted June 23, 2003 Share Posted June 23, 2003 Hello all, I\'m new here and hope that someone has the answer of a real beginner. I\'ve read several tutorials but what i want isn\'t working. I have a little table with some fields: CREATE TABLE prod ( name varchar(100) NOT NULL default \"\", nr int(5) NOT NULL, descr text NOT NULL, PRIMARY KEY (nr), UNIQUE KEY nr (nr), UNIQUE KEY name (name) ) TYPE=MyISAM COMMENT=\"Products\"; I have a working php program to add data to the database. I also have a little php program to list all records in the database. Now i need a program that can be called with a parameter to show all fields of a product like: http://localhost/pdc/listprod.php?prodnr=3 My program looks like this: <? include \'db.php\'; ?> <html> <head> <title>Products/title> </head> <body bgcolor=\"#ffffff\" > <? # setup SQL statement $sql = \" SELECT * FROM prod WHERE nr = \'$prodnr\'\"; # execute SQL statement $rs = mysql_query($sql, $cid); if (mysql_error()) { print \"Database Error: $sql \" . mysql_error(); } # display results print \"<p><b>Products</b><p>n\"; print \"<table border=0>\"; while ($row = mysql_fetch_array($rs)) { $name = $row[\"name\"]; $nr = $row[\"nr\"]; $descr = $row[\"descr\"]; print \"<tr><td>$name</td><td>$nr</td><td>$descr</td><tr>\"; } print \"</table>\"; ?> </body> </html> But, i get NO results! I\'ve made shure product nr 3 is in the database, i\'ve checked it with PHPMYADMIN. What am i doing wrone here? Can anybody point me in the right direction? Thanks in advace, Webguy Quote Link to comment https://forums.phpfreaks.com/topic/629-php-mysql-beginner-question/ Share on other sites More sharing options...
shivabharat Posted June 24, 2003 Share Posted June 24, 2003 ur code looks fine and I guess u have opened a database connection and also selected the database in ur include file also use the die command to check for error and u dont have to use a if to find that out. Quote Link to comment https://forums.phpfreaks.com/topic/629-php-mysql-beginner-question/#findComment-2109 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.