Josh is nearly correct.
Connecting to db:
NEVER pass your usernames, passwords, dbnames on this site or on any other. Since you have done it, after this, change them!
Define your names first:
define ("DBHOST", "localhost");
define ("DBUSER", "mayonaka");
define ("DBPWD", "182007");
define ("DBNAME", "grocery");
then make a dbconnect call:
function dbconnect()
{
$link = mysql_connect(DBHOST, DBUSER, DBPWD) or die ("Error: ".mysql_error());
mysql_select_db(DBNAME) or die("Could not select database: ".mysql_error());
return ($link);
}
-------
store these in a different file (hidden)
====
Your switch has no meaning: show_files is NOT a variable!
I assume you are trying to display rows 1-10, 11-20 etc
function show($id, $first) // receives two parameters: the ID (for the search), and the first record to show)
{
$link = dbconnect();
$sql = "select `vchrNAME`,`fltPRICE` from `catalog` where `intID` = '".$id."' limit $first, 10";
// LIMIT to display 10 rows from "first" (1-10, 11,20 etc)
$res = mysql_query($sql) or die (mysql_error());
// your current error is that your query is incorrect: you have not selected a database. Since you have no check on your query, when you get to the function mysql_fetch_assoc, the ressource provided ($result in your code) does not exist, hence, error
echo ("
"); // you did not start your table!
while ($row = mysql_fetch_array($res))
// fetch_assoc will return array['NAME']
// fetch_array will return array['NAME'] and accepts array[0]
{
echo ( "" . $row['vchrNAME'] . " | " . $row['fltPRICE'] . " |
";
}
echo ("
"); // you did not close your table
mysql_free_result ($res); // always free your ressource: you build up in memory!
mysql_close($link); // CLOSE your database..
}
Now, to get the entries, just set "$first" and call the function.
$id = something;
show ($id, "1");
show ($id, "11");
show ($id, "21"), etc...