Log in

View Full Version : functions - help


NanoEntity
07-14-2001, 09:36 PM
CREATE TABLE menu (
id int(3) NOT NULL auto_increment,
linkid varchar(255) NOT NULL,
linktitle text NOT NULL,
link text NOT NULL,
PRIMARY KEY (id)
);


function menu() {
global $DB_site;

$link=$DB_site->query("SELECT * FROM menu WHERE id ORDER BY linkid ASC");
while ($row = mysql_fetch_array($link)) {
$output = "$row[linkid]";
$output .= "<a href=\"$row[link]?link=$row[id]\">".stripslashes($row[linktitle])."</a><br>";
}
return $output;
}



OK this only lists 1 link with 1 linkid menu

what I want is to have unlimited linktitles under assigned linkid menu

so I can have any number of menus with assiged links to it.

Any Idea how to code it useing the DB?

NanoEntity
07-15-2001, 05:56 AM
BUMP^

ANYONE?

zarkov
07-15-2001, 10:00 AM
Hey Im no expert but try leaving off the WHERE id part of the sql statement.


CREATE TABLE menu (
id int(3) NOT NULL auto_increment,
linkid varchar(255) NOT NULL,
linktitle text NOT NULL,
link text NOT NULL,
PRIMARY KEY (id)
);


function menu() {
global $DB_site;

$link=$DB_site->query("SELECT * FROM menu ORDER BY linkid ASC");
while ($row = mysql_fetch_array($link)) {
$output = "$row[linkid]";
$output .= "<a href=\"$row[link]?link=$row[id]\">".stripslashes($row[linktitle])."</a><br>";
}
return $output;
}

You want it to pull all records from the database.

Plus i think youd get more help if you posted in the right forum, this should be in PHP help forum not the hacks forum.
:)