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:

Monsterrr
  • Prospect
Status: Offline
Joined: Aug 04, 201013Year Member
Posts: 650
Reputation Power: 32
Status: Offline
Joined: Aug 04, 201013Year 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!
#2. Posted:
ObscureCoder
  • Resident Elite
Status: Offline
Joined: Jun 29, 201310Year Member
Posts: 211
Reputation Power: 13
Status: Offline
Joined: Jun 29, 201310Year 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.
#3. Posted:
Monsterrr
  • Prospect
Status: Offline
Joined: Aug 04, 201013Year Member
Posts: 650
Reputation Power: 32
Status: Offline
Joined: Aug 04, 201013Year Member
Posts: 650
Reputation Power: 32
ObscureCoder wrote
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.


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.
#4. Posted:
ObscureCoder
  • Resident Elite
Status: Offline
Joined: Jun 29, 201310Year Member
Posts: 211
Reputation Power: 13
Status: Offline
Joined: Jun 29, 201310Year Member
Posts: 211
Reputation Power: 13
Monsterrr wrote
ObscureCoder wrote
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.


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.
#5. Posted:
7en
  • V5 Launch
Status: Offline
Joined: Aug 16, 201211Year Member
Posts: 598
Reputation Power: 29
Status: Offline
Joined: Aug 16, 201211Year Member
Posts: 598
Reputation Power: 29
ObscureCoder wrote
Monsterrr wrote
ObscureCoder wrote
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.


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 ****.
#6. Posted:
Nineteh
  • New Member
Status: Offline
Joined: Sep 22, 20158Year Member
Posts: 13
Reputation Power: 0
Status: Offline
Joined: Sep 22, 20158Year 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.
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.