corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » Would this be PHP/mySQL or HTML/IMG SRC?


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author Would this be PHP/mySQL or HTML/IMG SRC?
liamC
Member

Registered: 28th Feb 04
User status: Offline
25th Jan 07 at 12:42   View User's Profile U2U Member Reply With Quote

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
25th Jan 07 at 13:06   View User's Profile U2U Member Reply With Quote

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
25th Jan 07 at 13:09   View User's Profile U2U Member Reply With Quote

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
25th Jan 07 at 13:11   View User's Profile U2U Member Reply With Quote

liamC
Member

Registered: 28th Feb 04
User status: Offline
25th Jan 07 at 13:19   View User's Profile U2U Member Reply With Quote

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
25th Jan 07 at 13:42   View User's Profile U2U Member Reply With Quote

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
25th Jan 07 at 13:48   View User's Profile U2U Member Reply With Quote

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
25th Jan 07 at 13:50   View User's Profile U2U Member Reply With Quote

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
25th Jan 07 at 13:51   View User's Profile U2U Member Reply With Quote

^ as above.

Remember that MySQL stores nothing but numbers and letters.....
liamC
Member

Registered: 28th Feb 04
User status: Offline
25th Jan 07 at 13:54   View User's Profile U2U Member Reply With Quote

Gotcha lads thanks.

I'll post back with with tears of joy or failure
liamC
Member

Registered: 28th Feb 04
User status: Offline
25th Jan 07 at 21:48   View User's Profile U2U Member Reply With Quote

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
26th Jan 07 at 09:56   View User's Profile U2U Member Reply With Quote

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
26th Jan 07 at 11:10   View User's Profile U2U Member Reply With Quote

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
26th Jan 07 at 13:25   View User's Profile U2U Member Reply With Quote

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...

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
nice imports AK General Chat 59 613
22nd May 05 at 14:03
by Adam Kindness
 
Imports AK General Chat 60 906
6th Feb 06 at 20:20
by AK
 
Hey, heres my car..... barx General Chat 32 1041
14th May 06 at 14:03
by loo_goblin
 

Corsa Sport » Message Board » Off Day » Geek Day » Would this be PHP/mySQL or HTML/IMG SRC? 29 database queries in 0.0193429 seconds