liamC
Member
Registered: 28th Feb 04
User status: Offline
|
With the help of peeps on here yesterday I managed to echo out a title and description using text from a database.
I would like a selection of images I have uploaded to the website to go along with the text displayed that the user can choose from using a selection of images in a way which the user simply presses the radio button alongside the image they want and that image simply displays alongside the text.
Would this have to be doing via PHP? Or is it possible to use radio buttons and a bit of code to display it via IMG SRC?
|
ed
Member
Registered: 10th Sep 03
User status: Offline
|
Not quite sure what you are trying to do, but does this sound right to you?
In your database you will have your columns title, and description. You could add another column into the database for image location. You can the call on that using the same php as you used to echo the title so your image code would be:
$image=mysql_result($result,0,"image");
<img src="<? echo $image; ?>" alt="Image Description" />
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
I'll upload an image of en example of what I want mate...2 tics.
[Edited on 25-01-2007 by liamC]
|
ed
Member
Registered: 10th Sep 03
User status: Offline
|
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
A quick mockup of what I want for the admin page.
I've done half of the admin page - Basically there are 4 boxes on the homepage, all which I want editable for the staff through an admin panel.
I have the title and desc working fine, and it successfully updates the homepage no bother, but I would like an image to go alongside the text, again which is chooseable by the user via some sort of radio button function a bit like the below.
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
when you insert the title and desc just insert the image location into another column - you then just echo the image field out whenever you want that image to appear.
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
quote: Originally posted by aPk
when you insert the title and desc just insert the image location into another column - you then just echo the image field out whenever you want that image to appear.
Does that mean the images therefore have to be uploaded to the database instead of just the webspace?
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
No just to the webspace, just put the location of them in the database.
Say your main page is www.corsasport.co.uk/index.php
And your image is in www.corsasport.co.uk/images/image1.jpg
If you wanted to called the image on the index page, in the database you would put the image location as images/image1.jpg
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
^ as above.
Remember that MySQL stores nothing but numbers and letters.....
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
Gotcha lads thanks.
I'll post back with with tears of joy or failure
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
OK, back to this fun
Stored all the image locations into the database but having trouble with the code recognising which radio button is checked so it knows which one to display.
I primarily have number 1 as default checked, so that one is chosen if the user doesn't choose a different one, but I am struggling how the code knows which one is checked?
Will I need to insert a series of IF statements?
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
when the user submits the form each of the radio buttons will have a different 'name' in the HTML - on the script recieving the submission it just needs to check which name was checked and insert the relevant image location into the database.
You could do this with a series of if/elseifs or case.
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
Yeah, I've done the values in the HTML, set them to 1,2 3 etc so need to make the if/else or case code within the PHP.
Getting there eventually, cheers for your help
[Edited on 26-01-2007 by liamC]
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
If else is probably a more long winded method than case TBH but easier to understand.
Perhaps you could change them from '1, 2, 3' to the image they will display....
...so radio button one could have a value of 'image_1' so when you insert it into the database you insert 'image_1' + '.jpg' for example.....just a thought...
|