You are viewing our Forum Archives. To view or take place in current topics click here.
I have an advanced programming question
Posted:
I have an advanced programming questionPosted:
Status: Offline
Joined: Aug 04, 201014Year Member
Posts: 650
Reputation Power: 32
Status: Offline
Joined: Aug 04, 201014Year Member
Posts: 650
Reputation Power: 32
I've been working on a website for a bit and have some questions that I'm rather stuck on if anyone could point me in the right direction that'd be great.
So the question I have is this, I have implemented a way for buyers to pay (x) amount of money and in turn will be (Sponsoring) an image.
I want to know how to get a specific image set inside a database or somewhere to be chosen at random and then sent in email to that user stating this will be your image etc.
I have some ideas but not sure where my brain is going with them so if anyone has a clue that'd be great! Thanks in advance!
So the question I have is this, I have implemented a way for buyers to pay (x) amount of money and in turn will be (Sponsoring) an image.
I want to know how to get a specific image set inside a database or somewhere to be chosen at random and then sent in email to that user stating this will be your image etc.
I have some ideas but not sure where my brain is going with them so if anyone has a clue that'd be great! Thanks in advance!
#2. Posted:
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 211
Reputation Power: 13
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 211
Reputation Power: 13
Monsterrr wrote I've been working on a website for a bit and have some questions that I'm rather stuck on if anyone could point me in the right direction that'd be great.
So the question I have is this, I have implemented a way for buyers to pay (x) amount of money and in turn will be (Sponsoring) an image.
I want to know how to get a specific image set inside a database or somewhere to be chosen at random and then sent in email to that user stating this will be your image etc.
I have some ideas but not sure where my brain is going with them so if anyone has a clue that'd be great! Thanks in advance!
"Advanced" - I lol'd.
You could do it without a database but if you wanna use a data base:
create a table like:
id | img_loc
and make ID auto incrementing and img_loc a varchar of like 40 chars.
Then, add images like:
1 shit.jpg
2 wot.png
3 dafuq.png
4 notporn.png
and then select one using PHP w/ PDO. Just select one row and use ORDER BY RAND(). Then use mail() function or a wrapper like PHPMailer to email it.
Tip: only ever store locations of files in databases. BLOBs are stupid.
- 1useful
- 0not useful
#3. Posted:
Status: Offline
Joined: Aug 04, 201014Year Member
Posts: 650
Reputation Power: 32
Status: Offline
Joined: Aug 04, 201014Year Member
Posts: 650
Reputation Power: 32
ObscureCoder wroteMonsterrr wrote I've been working on a website for a bit and have some questions that I'm rather stuck on if anyone could point me in the right direction that'd be great.
So the question I have is this, I have implemented a way for buyers to pay (x) amount of money and in turn will be (Sponsoring) an image.
I want to know how to get a specific image set inside a database or somewhere to be chosen at random and then sent in email to that user stating this will be your image etc.
I have some ideas but not sure where my brain is going with them so if anyone has a clue that'd be great! Thanks in advance!
"Advanced" - I lol'd.
You could do it without a database but if you wanna use a data base:
create a table like:
id | img_loc
and make ID auto incrementing and img_loc a varchar of like 40 chars.
Then, add images like:
1 shit.jpg
2 wot.png
3 dafuq.png
4 notporn.png
and then select one using PHP w/ PDO. Just select one row and use ORDER BY RAND(). Then use mail() function or a wrapper like PHPMailer to email it.
Tip: only ever store locations of files in databases. BLOBs are stupid.
I'm not entirely sure what's to "lol" about but I do appreciate the answer even with the unprofessional smart ass remark.You have definitely pointed me in the right direction thanks.
- 1useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 211
Reputation Power: 13
Status: Offline
Joined: Jun 29, 201311Year Member
Posts: 211
Reputation Power: 13
Monsterrr wroteObscureCoder wroteMonsterrr wrote I've been working on a website for a bit and have some questions that I'm rather stuck on if anyone could point me in the right direction that'd be great.
So the question I have is this, I have implemented a way for buyers to pay (x) amount of money and in turn will be (Sponsoring) an image.
I want to know how to get a specific image set inside a database or somewhere to be chosen at random and then sent in email to that user stating this will be your image etc.
I have some ideas but not sure where my brain is going with them so if anyone has a clue that'd be great! Thanks in advance!
"Advanced" - I lol'd.
You could do it without a database but if you wanna use a data base:
create a table like:
id | img_loc
and make ID auto incrementing and img_loc a varchar of like 40 chars.
Then, add images like:
1 shit.jpg
2 wot.png
3 dafuq.png
4 notporn.png
and then select one using PHP w/ PDO. Just select one row and use ORDER BY RAND(). Then use mail() function or a wrapper like PHPMailer to email it.
Tip: only ever store locations of files in databases. BLOBs are stupid.
I'm not entirely sure what's to "lol" about but I do appreciate the answer even with the unprofessional smart ass remark.You have definitely pointed me in the right direction thanks.
The use of the word "advanced" is to lol about. However, I guess difficulty perception is subjective.
- 0useful
- 0not useful
#5. Posted:
Status: Offline
Joined: Aug 16, 201212Year Member
Posts: 598
Reputation Power: 29
ObscureCoder wroteMonsterrr wroteObscureCoder wroteMonsterrr wrote I've been working on a website for a bit and have some questions that I'm rather stuck on if anyone could point me in the right direction that'd be great.
So the question I have is this, I have implemented a way for buyers to pay (x) amount of money and in turn will be (Sponsoring) an image.
I want to know how to get a specific image set inside a database or somewhere to be chosen at random and then sent in email to that user stating this will be your image etc.
I have some ideas but not sure where my brain is going with them so if anyone has a clue that'd be great! Thanks in advance!
"Advanced" - I lol'd.
You could do it without a database but if you wanna use a data base:
create a table like:
id | img_loc
and make ID auto incrementing and img_loc a varchar of like 40 chars.
Then, add images like:
1 shit.jpg
2 wot.png
3 dafuq.png
4 notporn.png
and then select one using PHP w/ PDO. Just select one row and use ORDER BY RAND(). Then use mail() function or a wrapper like PHPMailer to email it.
Tip: only ever store locations of files in databases. BLOBs are stupid.
I'm not entirely sure what's to "lol" about but I do appreciate the answer even with the unprofessional smart ass remark.You have definitely pointed me in the right direction thanks.
The use of the word "advanced" is to lol about. However, I guess difficulty perception is subjective.
You're doing a great job of making yourself look like a ****.
- 4useful
- 0not useful
#6. Posted:
Status: Offline
Joined: Sep 22, 20159Year Member
Posts: 13
Reputation Power: 0
Your column should be something like donate_images.
Your rows should be:
imgurl varchar(120)
constant varchar(1) DEFAULT 0
id (120)
Then add your images, ID++ each time.
Now to randomise your images, you want to call each out of the database storing them in variables.
so:
$i = 1;
$variable = "";
then do your while statement to call all your images out and for each result['imgurl'] set it to equal $variable$i.
then increment $i.
Once this is done, you should have $variable1, variable2, variable3 etc...
Write a little php code which just randomly selects 1, you can just google this code.
Your rows should be:
imgurl varchar(120)
constant varchar(1) DEFAULT 0
id (120)
Then add your images, ID++ each time.
Now to randomise your images, you want to call each out of the database storing them in variables.
so:
$i = 1;
$variable = "";
then do your while statement to call all your images out and for each result['imgurl'] set it to equal $variable$i.
then increment $i.
Once this is done, you should have $variable1, variable2, variable3 etc...
Write a little php code which just randomly selects 1, you can just google this code.
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.