Jump to content


  • Content count

  • Joined

  • Last visited

Everything posted by Weiss

  1. fetch the data

    hi. i have an array with 8 id numbers (e.g. [4234, 3241, 2313, ....]; i have an sql table with those id numbers among others.. i want to make a query with fetch the data, i can do that with using IN (4234,3241....) but the problem is that i get the data when its oredered by numbers from small to big.. i want it oredered exactly as the array meanning the first row should be with id = 4324, second with 3241 etc... how can i do that? thanx
  2. joinning 3 tables

    Hi. i have 3 tables: orders, customer, custwish. (every table has id prim key, which match the 3 tables, meaning, if a customer has id=20, there's an order with id=20 regarding him and wishid=20 regarding him) i wanna make a query where ill get all info from these tables with the following restrictions: orderid=customerid=custwishid ; livearea(in table customer) =1, delivered(in table orders)= 'n' how can i do that with inner join? thanx!
  3. Well..this cant be right

    Hi. im almost sure im doing something terribly wrong... here goes: i have 2 tables, one for Customer (ID(primary)address,phone...etc..) and one for Order (OrderNumber(primary), order info, date of the order....etc) (both primary auto inc) both have foreign keys which point to the other tables primary key.. Now, when a new order is being made, i insert data to the Order table.... after that i need to insert data to the customer table... So... when i insert data to the order table, i cannot insert data to the foreign key column since i do not know what will be the data inside the primary key column of the customer table. so, now the primary key data in a variable, and go to the customer table and insert the data of the customer and in the foreign key i spit out what was in the variable i saved earlier, after i run the sql command line i can see the id key that have been issued so i save that in a variable. so i have to go back to the order table and insert the data in the foreign key there and NOW i have data in the 2 tables which is connected thru the foreign keys. this MUST be wrong there's no way im doing it right... right?
  4. primary and foregin key

    HI! im having a little understanding problem about keys. i have 2 tables. one with ID (primary key) and all kind of other stuff. now i have another table, e.g. adress, where i want to make a uniqe coloum connecting 1 to 1 with the ID of the main table. so what i did is connected the ID (primary key) of the first table to the ID (secondary key) of the second table. so how does that work now? because i cant insert anything to the second table since it gives me an error: #1452 - Cannot add or update a child row: a foreign key constraint fails (`logitech`.`cust_time`, CONSTRAINT `cust_time_ibfk_1` FOREIGN KEY (`order_num`) REFERENCES `customer` (`order_num`)). how can i use the second table exactly? in this situation, the data to the second table should be inserted only a few days after the data to the first table. thank you !
  5. primary and foregin key

    the idea is this, this first table get filled when customer buy product (primary key is order number which is uniqe, his id, address, name, etc.) the second table is inserted after a few days when the customer enters the site and checkbox his day and time request for when he want the package to arrive. so actually the second table doesnt get inserted at the same time the first one. ive made the first table order number a primary key and wanted to make the second table order number as secondary key so they both point to each other. if i insert null value on the second table key how will it point to the firs table?
  6. primary and foregin key

    i dont think i understand. those are 1 to 1 tables. i can enter data to the main table but how will the data be insreted to the second table if i get an error and i try to insert?
  7. Working with dates

    waow thanx very much
  8. Working with dates

    Suppose i wanna make a page where a customer enters, and he will see the days of the next week, like if im entering the page today (wednesday september 6th) i will see a table with the following week, starting from sunday september 10th to saturday september 17th. is there a way php can do such thing?
  9. syntax error maybe?

    Hi. ok ive been working for about 2 hours on 2 lines that for some reason doesnt work. i have a form with 2 inputs: order# and phone#. when user press submit i want it to search the DB. if he entered both phone# and order# the query will be other than if he entered only one of them. so actually i have 4 cases. 1: user submitted without phone# and without order# 2: user submitted with phone# but without order# 3: user submitted without phone# but with order# 4: user submitted with both. can someone help me with the syntax? ive been working on it for freaking hours and it doesnt seem to work.
  10. syntax error maybe?

    Yes thank you, realised that just now. do you think there's a better way to attack this other than all this nested if's ? btw, if isset returns true all the time do i still need it? or can i just use the !empty?
  11. syntax error maybe?

    one problem i noticed is that if i use if (isset($_GET['phonesrch'])) if (isset($_GET['order_num'])) they ALWAYS return true, even if i submit empty form. why is that?
  12. syntax error maybe?

    if (isset($_GET['submit'])){ $flag =1;//1 means both phone# and order# are entered if (!isset($_GET['order_num'])) { if (!isset($_GET['phonesrch'])) {$flag=2;} //means order# isnt set and phonesrch isnt set else{ $flag=3; }//means order# isnt set but phone# is set } else {if (!isset($_GET['phonesrch'])) {flag=4;} //means order# is set, phone# isnt } this is my code but somewhere i guess theres a syntax error
  13. edit button on php table created from sql DB

    solved it with a href thanx for your time
  14. Hi! Im making a php script which goes over an MySQL DB and present the Db as Table (its actually a db of customers where there's info of their ship address, phone, etc). so the php script fetch array and take 1 row at a time, and ofcours go thru all the elements in the DB and present it in a table. I wish i can make an EDIT button at the end of each row where the user can press it and it will move it to another (already made) edit user php script with the row Customer number. of cours i can end each line with a button but how can i make it so that after all the table has been printed out (maybe 250 rows) each button at the end of the row will lead to the edituser.php with the specific row customer number? any idea? thanks in advance
  15. edit button on php table created from sql DB

    :| still not working.. i dont understand how can i use post method and comine it with $_GET on the second script. ANYWAY, maybe A HREF is a better option but is there a way to let the user click on <a href> and send it with $order_num data? thanks very much again for your your time
  16. edit button on php table created from sql DB

    while ($row = mysqli_fetch_array($data)) { echo '<tr>'; echo '<td>'.$row['order_num'].'</td>'; echo '<td>'.$row['cust_name'].'</td>'; echo '<td>'.$row['store_name'].'</td>'; echo '<td><form method="get" action="findorder.php?order_num='.$order_num.'"><input type="submit" name="testing" value="Edit" /></form></td>'; } doesnt work thanx very much though dsonesuk, posted the code maybe someone will be able to fix this
  17. edit button on php table created from sql DB

    Well if i do this i get directed to the findorder.php. my url shows: http://localhost/logitech/findorder.php?testing=Edit when i echo $this_order i get nothing when i echo $this_this i get: Edit
  18. edit button on php table created from sql DB

    when i try doing this: echo '<td><form method="get" action="findorder.php"><input type="submit" name="testing" value="Edit" /></form></td>'; i get redirected to: http://localhost/logitech/findorder.php?testing=Edit .. i can use $_GET['testing'] but it will give me whaever in the value which is "Edit".. i cannot change the value because it will change the writing on the button
  19. edit button on php table created from sql DB

    echo '<td><form action="findorder.php?'. $order_num.'"><input type="submit" value="edit" /></form></td>'; doesnt seep to work... above is the line that create the edit button, (order_num is uniqe in the database), but when pressed, it send the user to the findorder.php? with no order_num.. what am i doing wrong here?
  20. Working with dates

    You sir, are the best. thank you!
  21. Working with dates

    Hi. i have a table with a date row. i have 2 problems with it. first, it saves the date as mm-dd-yyyy and i actually need it to save it as dd-mm-yyyy. the second problem is more of a question.. after a date has been saved, can i use it to calculate? can i calculate and output this date + day for example? thanks in advance
  22. Working with dates

    Thanks! so correct me if im wrong, by reading your comment, its best to keep the data in database as deafult yyyy-mm-dd so i can have calculations. if my customer want to see it in dd-mm-yyyy i can retreive the data and manipulate it while echoing in the php code? is that what i should do?
  23. <select> inside a form

    Hi all. Soo.. im creating this form where one of the fields the user have to select his city.. i want him to select from a list with all the cities in our country, of cours we hace more than 1.5k cities.. i imagine theres a better way to handle this other than go city after city inside <option>.. right? Thanks in advance
  24. <select> inside a form

    Back to the topic, as mentioned i need to make a select list with 1.5k cities. Is there a quick way to do that?
  25. <select> inside a form

    I actually dont live in the U.S.. in here we just have country name and then city name