01. februar 2006 - 21:29Der er
5 kommentarer og 1 løsning
hent fra to tabeller i databasen
CREATE TABLE catrecipe ( catID int(11) NOT NULL auto_increment, cat_title varchar(200) NOT NULL default '', PRIMARY KEY (catID) ) TYPE=MyISAM;
INSERT INTO catrecipe VALUES (1, 'Barbecue');
CREATE TABLE recipe ( recipeID int(11) NOT NULL auto_increment, recipe_title varchar(200) NOT NULL default '', recipe_ingredients text NOT NULL, recipe_method text NOT NULL, recipe_note text NOT NULL, catID int(11) NOT NULL default '0', PRIMARY KEY (recipeID) ) TYPE=MyISAM;
hej
har et lille problem med at hentet fra to tabeller hvordan for jeg oplyst navnet der står i catrecipe i f.eks. value 1 når dette script tæller og viser titlen på hvad der står i tabellen recipe
<?php include('lib/config.php'); $query = mysql_query("SELECT recipeID,recipe_title,catID FROM recipe ORDER BY recipeID DESC LIMIT 20") or die(mysql_error());
while ($row = mysql_fetch_assoc($query)) { if ($i++ != 0) echo '<div class="hr"></div>'; echo '<strong>Kat.: '.$row[' catID'].' Titel '.$row['recipe_title'].'</strong>.'; } ?>
<?php include('lib/config.php'); $query = mysql_query("SELECT recipeID,recipe_title,cat_title FROM recipe, catrecipe WHERE recipe.catID=catrecipe.catID ORDER BY recipeID DESC LIMIT 20") or die(mysql_error());
while ($row = mysql_fetch_assoc($query)) { if ($i++ != 0) echo '<div class="hr"></div>'; echo '<strong>Kat.: '.$row[' cat_title'].' Titel '.$row['recipe_title'].'</strong>.'; } ?>
har ændret den til men nu kommer kun kategorien frem ???
<?php include('lib/config.php'); $query = mysql_query("SELECT recipeID,recipe_title,cat_title FROM recipe, catrecipe WHERE recipe.catID=catrecipe.catID ORDER BY recipeID DESC LIMIT 10") or die(mysql_error());
while ($row = mysql_fetch_assoc($query)) { if ($i++ != 0) echo '<div class="hr"></div>'; echo '<strong>'.$row[' recipe_title'].'</strong> (Kat.: '.$row['cat_title'].').'; } ?>
<?php include('lib/config.php'); $query = mysql_query("SELECT recipe_title,cat_title FROM recipe, catrecipe WHERE recipe.catID=catrecipe.catID ORDER BY recipeID DESC LIMIT 10") or die(mysql_error());
while ($row = mysql_fetch_assoc($query)) { if ($i++ != 0) echo '<div class="hr"></div>'; echo '<strong>'.$row['recipe_title'].'</strong>.('.$row['cat_title'].')'; } ?>
Du får lige et svar (har af en eller anden grund først modtaget mails nu >_>)
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.