Maian Script World on Facebook Maian Script World on Twitter Maian Script World - Latest News Maian Script World on YouTube Maian Script World on LinkedIn


Please Read

You are required to register before you can post. This is via a custom verification system. Please post any problems you are encountering here and I`ll do my best to respond as soon as I can. Please note that a reply WILL be posted to all queries, so do not double post. There are no guarantees when a reply will appear but I do my best to answer all within 3/4 days max. Bumping topics won`t make the slightest difference.

IMPORTANT: Posts in English ONLY please, thank you! Any other languages will be ignored and your message deleted.
SEARCH: Use the search option to see if your question has been answered on the forum before. Or check the relevant script docs.
CUSTOMER: If you have purchased a commercial version of any of my software, using the contact option at the licence centre ensures a faster response.
AUTO DELETION: Accounts older than 5 days, with no posts or topics, are automatically deleted. Only register if you are thinking of posting.
PRIVATE MESSAGES: Private messages are currently disabled.
LINKS: Any links posted are 'NOFOLLOW' and will not be picked up by search engines.

You are not logged in.

#1 21-03-2012 10:17:24

lecra
Members
Registered: 13-02-2010
Posts: 33

Receipe of the day

Hi all,

Anybody that has already implemented, or is willing to help me in implementing a 'recipe of the day' on the front side?

The idea is to pick up a randomly recipe from the database and put the title, and a possible image on the front side. Clicking on it (image or title) would forward the user to the recipe.

I have no clue how to implement it as I'm completely a PHP noob!

Any volunteers?

KR; Lecra

Last edited by lecra (21-03-2012 10:17:58)

Offline

#2 22-03-2012 07:31:45

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,066

Re: Receipe of the day

Hi Lecra,

This isn`t so difficult, so here goes:

1. First you need to get a random recipe:

$q = mysql_query("SELECT * FROM mr_recipes WHERE enRecipe = 'yes' ORDER BY rand() LIMIT 1");
$RECIPE = mysql_fetch_object($q);

So, the $RECIPE object now holds the info you need. Title would be:

<?php
echo $RECIPE->name;
?>

2. Next grab an image. You can do random for that too if there are more than 1:

$q2 = mysql_query("SELECT * FROM mr_pictures WHERE recipe = '{$RECIPE->id}' ORDER BY rand() LIMIT 1");
$IMG = mysql_fetch_object($q2);

3. Display image:

<img src="templates/images/recipes/<?php echo $IMG->picPath; ?>" alt="" title="" />

Try that. I`ll leave you to the design part of things.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

#3 22-03-2012 10:57:43

duceduc
Members
From: Japan
Registered: 25-05-2010
Posts: 359

Re: Receipe of the day

This gives me an idea.

What if we want the same image to stay for one day, when we refresh the page, will the image/recipe change as well?

Offline

#4 22-03-2012 15:45:22

msworld
Administrator
From: United Kingdom (Great Britain)
Registered: 09-05-2006
Posts: 7,066

Re: Receipe of the day

Its always random above. To have the same don`t use random.


- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
David Ian Bennett - Lead Developer
www.maianscriptworld.co.uk

Offline

Board footer

2Checkout.com is an authorized reseller of goods and services provided by Maian Script World.© 2003-2013 David Ian Bennett. All Rights Reserved | Forum: FluxBB

Privacy Policy | Refund Policy