Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Posts posted by jimfog

  1. Suppose I go for 2 tables plus the lookup(service providers, services, lookup for these 2). I assume I must foreign keys, which means using innoDB, correct?

  2. I found in the web this line of code which I am having difficulty in finding what exactly the constraint keyword does plus the value next to it: CONSTRAINT tb_pk PRIMARY KEY (ProviderID),I ran the above query(and as guess) it a column named ProviderID which is going to be also the primary key.The words though "CONSTRAINT tb_pk" seem to have any effect at all. Sorry if I am putting this question here-If I have to, I will create a new topic. It seems CONSTRAINED is used to give a name to a primary key, but why we would want to do that?

  3. As a sidenote and in relation to primary keys...if I set something as auto increment does that means THAT automatically gets to become a primary key. The above question does not relate in anyway with the uniqid example I mention above.

  4. I am little confused as to what MySQL version to download and install in my machine. In the PHPMyAdmin homepage I see this entry: Software version: 5.1.63-community - MySQL Community Server (GPL) As I understand this must be old and the latest being MySQL Community Server 5.5. Should I download the above you think? Are there big differences?

  5. VARCHAR(XXX) or some similar string based type, and then just store it as CSV. Or make two tables, one for service provider, and another table for services. each service will have a foreign key to the service provider table.
    As I see there is no way of having individual columns in CSV. The whole table must be in CSV.
  6. I'm saying that your definition of "complicated" is relative. To me, 2 tables with a lookup table is not "complicated", it is "necessary" for a many-to-many relationship that you want to store in a meaningful way in the database. If you have a one-to-one relationship then you can use a single field to store the relationship, if it is a one-to-many relationship between services and providers...
    First of all,because you are using terminology not so much familiar to me(I know some stuff though), some clarifications are needed. You are mentioning the term one-to-many relationship. Am I right to assume that when we have 1 provider and many services, that this is an example of one-to-many.Am I correct? So you are saying that with one-to-many I can still go with my original plan-one table only.Although I do not know how am I going to store all the services in one column. It would be certainly varchar,but I have no idea about the csv part mentioned above.Any hint would be helpful here.
    You don't have to take my word for it though, people learn by designing something and then figuring out where it fails. Go ahead with your plan and you'll find out where it fails.
    You are absolutely correct here.
  7. let us forget the searching feature for now.I know what a varchar is. I suppose you are mentioning varchar for the case I use one table after all and varchar will be the column type for the services. I say the db will become complicated when I opt for the scheme you are describing-multiple tables.

  8. it's pretty straightforward. It set a flag $wasFilledOutCompletely to an initial value of true.
    This is the point I do not understand...why use the flag and set it to true?
    You can't just use echo or print to output directly to the page?
    I thought you meant a proper debugger software...ok I got you now
  9. deviding the service and service provider to different table is the best way. if you implode all the service as text in service provider tablle it will not be efficient when query will search through the data.
    Yes, but I am afraid that this will complicate the table structure. I do not saying that you are not right about the query. My motivation is that it is better to have all the data related to a service provider in one table(services, name, address etc...)...but I maybe opt for your solution after all.
  10. It worked...thanks. Although I have not yet understand how the logic works in your code. My debugger(xdebug), currently is not operational, so, I cannot debug the code and see what is hidden under the hood I have not tried yet though what are you mentioning about the break statement...I intend doing it.

  11. Ok I got that...here is another problem I encountered relevant to the form again-checking if the fields are empty. Here is the function to check if the fields are empty:

    function filled_out($post){  // test that each variable has a value  foreach ($post as $key => $value) {	 if ($value == '') {	    return false;	 }elseif(!empty($value))	 { return true;}  }}

    It does not work as expected though.If 2 fields are filled and not others are filled the code proceeds as though the user filled in all of the fields. Here is the if statement that calls the above function.

    if(!filled_out($_POST))		 {echo 'you did not fill in all of the fields';}		 elseif(filled_out($_POST))		 {echo 'thanks';}	 }

  12. I have a form and above it(in the script) I have the following function called: if (filled_out($_POST)){ echo 'thanks for your detail.';} Here is the function:

    function filled_out($post){  	 if (isset($_POST)) {		return true;  }}

    I do not think it is necessary to show the form code-it is just a simple form with some fields.The problem is that when I go to the page where the form is and WITHOUT submitting it or filling the fields the "thanks for your details"is triggered. I cannot understand how the $_POST variable gets set since the submit button is not pressed. It seems that it gets set be just going to the page of the form-something strange, as far as I know. I must say that the form and the form action are in the same page(although this does not play role here). The funny thing is I erased the form and still the if statement output true.I cannot figure out from where this post array gets set-probably I will have to post the whole script. In addition to the above, I used var_dump to check what is contained in the $_POST array and I get(as expected) the following:

    array (size=0)  empty

  13. since I have not done such a column type before I need to make the following question. Will the size of the varchar depend on the size of the characters of the individual service or the total characters that might these occupy?

  14. suppose I want to a store in a table a column that will store services provided by a service provider.But I do not want to a separate row for each service, (because each row will be assigned to a separate service provider). I want the services listed in one row, for the reason I mention above. What kind of column typethat could be?

  15. Yes I have amended code. The code I finally used is with the eq method: $(this).parent().children("input").eq('5').after(field);In the above code, with the eq method, it seems only inputs are targeted and that is why and index of 5 will do the job-and not 7 in theother case

  16. I finally used this:

    $(this).parent().children("input:nth-child(7)").after(field);

    It was targeting the correct input element i wanted.In the beginning I tried negative indexes(-3) to start from the end, but it did not work. So, I used positive indexes. It is still strange though, cause the element I want to target(input element) in the form has an index of 5 and not 7.So, logically an index of 5 would do the trick. But instead I have to use an index of 7. Corrected code:

    $(this).parent().children("input").eq('5').after(field);

  17. well...I have another problem now, I added an input type submit button, and now, the newly created inputs go belowthe button. Cause now, the last input element is the button. Now, we have to take into consideration and this. I am going to search a solution to this myself too.

  18. Ok this works...I have 1 last question though. What I want to insert after the last input element are 2 other input elements.I have assigned these 2 input elements in one variable.

    var input= $('<input id="servc"size="40" placeholder="Service" type="text" name="Services"><input display="block" size="3" placeholder="Price" type="text" name="price">');

    Suppose I assign the second input element(the price) in a different variable,for code organisation purposes.Let as say the price variable.The services input field is assigned to a different variable

    var services;var price;var field=services+price;

    In essence I tried doing this:

    (this).parent().children("input:last").after(field);

    But I could not-is there a way to concatenate variables in the manner described above?So far, I have not managed to do it. I have tried several things.

×
×
  • Create New...