Jump to content
xisto Community
iGuest

[MYSQL] Drink List create a sorted list of recipes

Recommended Posts

product showcase question....

Category, Subcategory?

 

Ok, what I am trying to do is piece together a database of bar drinks. So far I compiled about 60 or so shots. So now what I am trying to do is go from index/drinks.Php, to take all the listings from the sql query on that page and turn them into a link, so when I click it, it will dynamically generate index/drinks/purplemf.Php and generate the recipie in that window...

 

 

 

All I have is the query for the shots listings, and the data entered in mysql, but I don't know how to turn the name into a link and dynamically generate the page itself from a template that I want to make...

 

 

 

I hope I explained this right lol.

 

 

 

Kinda like on a shopping site, you click on yhour product category, then the list of products come up, then you click on a specific product name, and it generates the template with all the information about that specific product.

 

 

 

-question by Antonio

Share this post


Link to post
Share on other sites

Ok, what I am trying to do is piece together a database of bar drinks. So far I compiled about 60 or so shots. So now what I am trying to do is go from index/drinks.Php, to take all the listings from the sql query on that page and turn them into a link, so when I click it, it will dynamically generate index/drinks/purplemf.Php and generate the recipe in that window...

Hmmn... ok, assuming that you have a php page for each drink, let's suppose that you have the following table:

+-------+-----------------+------+-----+-----------+----------------+| Field | Type            | Null | Key | Default   | Extra          |+-------+-----------------+------+-----+-----------+----------------+| id    | int(4) unsigned |      | PRI | NULL      | auto_increment || name  | varchar(64)     |      | UNI |           |                || page  | varchar(64)     |      | UNI | index.php |                |+-------+-----------------+------+-----+-----------+----------------+

Now suppose you have these data:

|  6 | Blood Type AB      | ab.php |
| 7 | Blood Type O | bo.php |
| 8 | Screaming Orgasm | so.php |
| 9 | Coke and Rum | cr.php |
| 10 | Ginger Ale | ga.php |
| 11 | Polyjuice Potion | pj.php |
| 12 | Pumpkin Juice | pk.php |
| 13 | Butterbeer | bb.php |
+----+--------------------+--------+ linenums:0'>+----+--------------------+--------+| id | name | page |+----+--------------------+--------+| 1 | Martini | mt.php || 2 | Vodka | vd.php || 3 | Bloody Mary | bm.php || 4 | Margarita | mg.php || 5 | Wizard's Mind Bomb | mb.php || 6 | Blood Type AB | ab.php || 7 | Blood Type O | bo.php || 8 | Screaming Orgasm | so.php || 9 | Coke and Rum | cr.php || 10 | Ginger Ale | ga.php || 11 | Polyjuice Potion | pj.php || 12 | Pumpkin Juice | pk.php || 13 | Butterbeer | bb.php |+----+--------------------+--------+
Your index.php will look something like this:

  $name = $row['name'];
echo "<p><a href='$page'>$name</a></p>";
}

... OTHER STUFF HERE ... linenums:0'>... INITIALIZATION GOES HERE ...mysql_connect(DB_HOST, DB_USER, DB_PASS) or die(mysql_error());mysql_select_db(DB_NAME) or die(mysql_error());$result = mysql_query("SELECT name, page FROM drinks ORDER BY name");while ($row = mysql_fetch_assoc($result)) { $page = $row['page']; $name = $row['name']; echo "<p><a href='$page'>$name</a></p>";}... OTHER STUFF HERE ...
This will give you a list of links to your drinks' recipes ordered alphabetically by drink name.

Hope this was of help to you :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.