Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   PHP (http://www.programmingforums.org/forum29.html)
-   -   efficient (http://www.programmingforums.org/showthread.php?t=15028)

kishou Jan 24th, 2008 10:22 PM

efficient
 
ok i just finished making my comment script for pictures. but i would have to create a new table each time and now its starting to become very tedious :@. So i was wondering is there a way to make my script more efficient? like mabye only select some rows? or insert into different parts of 1 table? thanks.

Jimbo Jan 25th, 2008 1:40 AM

Re: efficient
 
For those of us who don't have your project specs, what tables? What pictures? What comments? What are you doing?

kishou Jan 25th, 2008 2:22 AM

Re: efficient
 
Quote:

Originally Posted by Jimbo (Post 140244)
For those of us who don't have your project specs, what tables? What pictures? What comments? What are you doing?

lo siento :(. ok i made a database for comments. and when u add a comment it inserts it into the table. and i have a section called comments on the page with the picture and all that does is just select the table.

Sane Jan 25th, 2008 6:06 AM

Re: efficient
 
You might need to post some code. With your current descriptions, the problem at hand is too ambiguous. I doubt anyone could suggest the necessary code to make it more efficient. Post the script?

kruptof Jan 25th, 2008 8:30 AM

Re: efficient
 
I'll just take a SWAG.

You have two items a picture and a comment and a comment is associated with a picture. You want to be able to retrieve a given picture and its comment.

Have a single table, lets call it TableX, this table will have minimum 2 columns 'Picture' and 'Comment'. When you need to store an image and it's comment just use a INSERT statement or something equivalent to append data to the table and when you want to retrieve something from the table use the SELECT statement or something equivalent.

Note the INSERT and SELECT are sql keywords and note php.

kishou Jan 25th, 2008 3:02 PM

Re: efficient
 
Quote:

Originally Posted by kruptof (Post 140265)
I'll just take a SWAG.

You have two items a picture and a comment and a comment is associated with a picture. You want to be able to retrieve a given picture and its comment.

Have a single table, lets call it TableX, this table will have minimum 2 columns 'Picture' and 'Comment'. When you need to store an image and it's comment just use a INSERT statement or something equivalent to append data to the table and when you want to retrieve something from the table use the SELECT statement or something equivalent.

Note the INSERT and SELECT are sql keywords and note php.

thanks! but would there still be able to be a field like name,email,comment? cause thats what i aiming for. and thx for all of your help so far!
my script is just an insert select. here's an example:
http://pspstuff.elementfx.com/comment.html

Jimbo Jan 25th, 2008 7:34 PM

Re: efficient
 
I think you want 2 tables, one for pictures and one for comments. Assign each picture an ID, and use that ID to tell what comments correspond to what pictures. Then you can do something like 'SELECT * FROM Comments WHERE PictureId = <picId>' to get all the comments for that picture. Is this close?


All times are GMT -5. The time now is 12:49 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC