Jump to content

Putnammj

New Members
  • Posts

    9
  • Joined

  • Last visited

Everything posted by Putnammj

  1. Hi Guys, I have a search box on the site I am creating and when a user types their postcode in it the database is searched and members covering that location are shown. I have the following which works fine ... but: --------------------------------------------------------------------------------------------------------------- $postcode = mysqli_real_escape_string($myConnect, $_POST['searchbox']); #Convert the post code to upper case and trim the variable $postcode = strtoupper(trim($postcode)); #Remove any spaces $postcode = str_replace(" ","",$postcode); #Trim the last 3 characters off the end $postcode_wc = substr($postcode,0,strlen($postcode)-3); ------------------------------------------------------------------------------------- The problem i have is that if the user just types in the first part of the poscode such as SW1 it is then trimmed to zero characters or SW10 is trimmed to just S and this wont return the results! I need the last part of the code to only run if they enter 5 character or more! What should i add before or add to the last part of the code (shown in bold) Please Help! Thank you in advance kind souls!!!! Mark
  2. Thank you thats fantastic will give that a go! Would i then just link the members table to the members_areacode table via the member_id with a one to many relationship?
  3. Ah thats fantastic thank you!!! That will make the table much smaller and more managable! I had hoped to go this way but i thought that having multiple entries of each member_id would not work. 1) Would i set the primary key as the member_id and would that work ok if it is duplicated in multiple rows? 2) do I not need to make one of the columns "unique"? Thank you so much for the advice!!!!
  4. Thanks Andy you are a star! I think I understand now Please take a look at the image I've attached and let me know if that layout would work ok or if there is a better way! Thanks again I really appreciate your help! Mark
  5. Andy, thanks so much for the reply!! Sorry for not being clear, members and companies are the same thing, the companies would be my members. I want users of the website (no login required) to type the postcode where they live and for companies that cover that location to appear. Companies will cover several postcode areas. Table 1 will have details of the company and how to contact them by phone or email etc and the second table which I will need to link to the first table to will contain postcodes within the uk that they cover. I am unsure how to lay out this second table for postcode areas they cover (there are 3000 postcodes in the uk) and how to link it to the first table? Eg what columns would I need in the postcode table? Maybe like this: Member_id. Sw1. Sw2. Sw3. Every postcode in uk in separate column 1 Yes. Yes. Etc Any help would be much appreciated on how to lay out the second table and how to link the two tables so the user can search by postcode Thanks again your help is so very much appreciated!!!! Mark
  6. Hi all, Please help it's driving me insane, I'm really hoping someone can help me with this. I have a MySQL database which shows companies that cover certain postcodes (zip codes) within the uk. My first table "members" contains member_id, company_name, contact_number and email address. I need to design a second table to contain the post codes they cover (there are nearly 3000 in the uk). I am really struggling on knowing how to lay this table out and need your advice please! Eg should I have a column for each postcode and write the member_id in that column in a new row if they cover that postcode? Basically i am clear on the first table but I don't know how to lay out the second table for postcodes and how I would link the member_id to the postcodes they cover (some companies will cover 20 post code areas and I understand I can't just have multiple postcode areas in the same column/row? So if member-id 1 and member-Id 2 covered sw1, sw2, sw3 etc how would that work? I just need a clear advice on how that postcode table should be laid out and linked to the first members table so that when a user types a postcode in to the search page e.g SW1 the companies covering that postcode appear. Many thanks in advance! Any advice would be very much appreciated! Mark
×
×
  • 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.