Jump to content

Recommended Posts

Good afternoon, 

 

I hope you are all well. 

 

I have been learning programming languages but I have done more theory than practice. I've decided it will be best to continue learning by coding a project I'm interested in. 

Now, if you don't mind, I need assistance on the route to take and what to research. 

 

The site works like a classified ads site - users can upload an item for sale in a predetermined category for a set price with pictures / location / condition / description / etc. or they can browse, ask questions and buy. There will obviously be a login page and user accounts. The home page would preferably also display most recent additions. 

 

I'm assuming most of this is data stored in a database.

 

Firstly, how would you advise the tables are structured - would you have one be for login/user details, one for ads, separate table for photos? 

If the questions are to be sent to user email is this a matter of calling their email from the table on the form page?

How would I create the ad layout that all others follow?

Is it a simple task to allow users to delete their ads if they wish?

When the results are returned, again, how is the layout of the results configured and how is the number restricted to so many a page?

 

I am sorry for the questions. 

I feel I have read so much but without physically building something I don't think it'll fit in. 

It's the working out of 'what goes where' / 'what will make that happen' I'm finding trickiest. 

 

And any further advice would be greatly appreciated, 

Thank you for your time, 

Pica

Link to comment
https://forums.phpfreaks.com/topic/285861-user-inputted-ad-site/
Share on other sites

I will attempt to answer this given the limited information you've provided.

 

To address the database problem you're having first I would write down every piece of information you want the user to provide for the item, question and answers, user information etc, and then use that to create a model. Below I've done a quick model. Keep in mind, I don't know the full details of this application.

 

The tables are as follows:

  • User
  • Advertisement
  • Photo
  • Question
  • Answer

If you want the user to upload more than one photo you would need a separate table. You would need to create a one-to-many relationship between the advertisement table, and the photos table. Below is a mock DB structure:

Advertisement
#############

id (Primary Key)
user_id (Foreign Key)
title
tagline
description
pictures
location
condition
created_at
updated_at
deleted


Photo
#####
id (Primary Key)
advertisement_id (Foreign Key)
location
created_at
updated_at
deleted

User
####

id (Primary Key)
first_name
last_name
email
password
status
role
created_at
updated_at

Question
#######£
id (Primary Key)
user_id (Foreign Key)
advertisement_id (Foreign Key)
question
created_at
updated_at
deleted

Answer
######
id (Primary Key)
user_id (Foreign Key)
answer
created_at
updated_at
deleted

If you don't understand primary keys, and foreign keys, I'd hit Google for a refresher. I've added delete columns to most of the tables which will allow you to soft delete. Especially useful if police contact you for information on an advertisement posted. You still have hard evidence. Or unless the user changes their mind and wants to re-list.

 

I'd also probably store the users IP address, and log all the IP addresses they use. This is useful for banning users, especially spammers. Spammers are all over classifieds sites.

 

I'd also probably store stuff like contact information. And probably only allow prospect buyers to email sellers via the site. I.e. you forward the email to the seller from the buyer, and do the same from the buyer when the seller replies.

 

Ensure you understand relationships and normalisation in a rational database.

 

 

 

 

If the questions are to be sent to user email is this a matter of calling their email from the table on the form page?

 

Not sure what you mean by this, sorry.

 

 

 

How would I create the ad layout that all others follow?

 

Again I'm not sure what you mean by this.

 

 

 

Is it a simple task to allow users to delete their ads if they wish?

 

Pretty much. You're going to want to create a CRUD interface (create, read, update, delete). Or, create an API that makes use of various HTTP verbs.

 

 

 

When the results are returned, again, how is the layout of the results configured and how is the number restricted to so many a page?

 

When the results are returned from the database? I.e. pulling an advertisement from the database, along with its questions?

 

If that's the case, they can be returning in a number of ways depending on what abstraction layer you use to access the data from the database. If it's PDO, then you can return the results in a number of ways, more commonly an array, or an object.

 

Hope that helps.

Edited by imageek
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.