Jump to content

question about setting up table for php/mysql phone directory


music_lp90

Recommended Posts

Hi, I'm creating an online phone directory for a site and am looking for suggestions on setting up my mysql table. The directory will list first and last names of the head(s) of the household, names of any others living with them, their home phone, cell phone, mailing address, email, and a picture if we have one for the listing. Right now I set the table up like this:id INT(11) auto_increment primary keylastname TEXTfirstname TEXTothernames TEXTphone TEXTcell TEXTaddress TEXTemail TEXTImgTitle VARCHAR default UntitledImgType VARCHAR default jpgImgData MEDIUMBLOBDoes this seem like a good way to set the table up? Any suggestions would be greatly appreciated, I'm pretty new at this. Thanks!

Link to comment
Share on other sites

Don't make everything text. Text is for large blocks of text, most of those are just small text strings. Use varchar for most of those columns and set the length of each one appropriately. Don't use any more then you think you need. Also, it might be better (it would definately be faster) to save the image as a file on the server and just save the filename in the database instead of saving the image data in the database. It takes a small delay for PHP to get the data from the database, create an image object, and output it to the browser. It's not a big delay, but it's noticeable.

Link to comment
Share on other sites

Thanks for the help. I think I will do the pictures like you said. That seems like it would be a better way. I've wondered about specifying how many characters are allowed for each of the fields. Does that help increase the speed by specifying the number of characters allowed in a field? or does it help save space? or something else? The reason I was going to put the image in the database was because I wanted whoever is updating the pictures to be able to upload the picture instead of having to type in the exact name of the picture's filename. Is there a way to allow them to just upload the filename, so they can browse for the file, select its name and upload the name to the database without uploading all of its data?Thanks for your help!

Link to comment
Share on other sites

If the file is already on the server you can have them just paste in the address of it. If it is on their computer then they can upload the file with the file input and PHP can get the file and move it where it needs to go, then save the name of it in the database.

Link to comment
Share on other sites

If the file is already on the server you can have them just paste in the address of it. If it is on their computer then they can upload the file with the file input and PHP can get the file and move it where it needs to go, then save the name of it in the database.
Thanks for the help, I'm not sure how to create a page to upload images to a directory on the server. I've been looking around on the internet for a few minutes, but have not found anything helpful yet. Is this something you could explain to me or point me towards a good resource. Thanks again, I really appreciate it.
Link to comment
Share on other sites

Thanks for the help, I'm not sure how to create a page to upload images to a directory on the server. I've been looking around on the internet for a few minutes, but have not found anything helpful yet. Is this something you could explain to me or point me towards a good resource. Thanks again, I really appreciate it.
http://w3schools.com/php/php_file_upload.asp
Link to comment
Share on other sites

Ok, I've got a question. When I'm writing the upload script, the file goes to a temporary folder (if I understand correctly) and I need to move it to a folder where it can remain permanantly. My problem is I don't know what my temporary folder is. How can I find what my temporary folder is? or how can I create the temporary folder for it?Thanks for your help!

Link to comment
Share on other sites

The path that the file was saved as is included in the $_FILES array, you can use that path with the move_uploaded_file function to move the file. Check the reference for move_uploaded_file for some examples.

Link to comment
Share on other sites

Thanks for all your help. I've got it working now. I have a question on displaying the directory now. I want to have 2 sets of links from a-z so people can browse for people whose first or last names start with the letter they click on. Is there a mysql or php function that returns results based on the first letter of the name.Thanks for your help!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...