Jump to content

maxat

Members
  • Posts

    15
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

maxat's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hi, I have a problem inserting multiple drop down list options into MySql database. No problem with text fields, only with drop down. Can you please help me with it? Code is below. <?php for($i = 1; $i <= $items; $i++) { echo " <tr> <td width=3% align=center>$i<input type=hidden name=\"qid[]\" ></td> <td align=center colspan=2><textarea name=\"a1[]\" cols=40 rows=2 id=box></textarea></td> <td width=20% align=center><input type=text name=\"a2[]\" size=10 maxlength=10 id=box></td> <td width=11% align=center><SELECT id=box name=\"unit\"><OPTION value=each>each </OPTION> <OPTION value=ltr>ltr </OPTION> <OPTION value=box>box </OPTION> <OPTION value=can>can </OPTION> <OPTION value=kg>kg </OPTION> <OPTION value=dr>drum </OPTION> <OPTION value=pair>pair </OPTION> <OPTION value=ton>ton </OPTION> </SELECT></td> <td width=19% align=center><input type=text name=\"a4[]\" size=4 maxlength=10 id=box></td> </tr>"; }?> <tr> <td align="right" colspan="5"><input name="btnSave" type="submit" id="btnSave" value="Save"></td> </tr> </table> </form> <?php if($_POST){ $enqNum = $_POST['enqnum']; $compNum = $_POST['comp']; $unit = $_POST['unit']; $date = date(); foreach($_POST['qid'] as $idx => $val) { $qid = $val; $item = $_POST['qid'][$idx]; $a1 = $_POST['a1'][$idx]; $a2 = $_POST['a2'][$idx]; $a3 = $_POST['a3'][$idx]; $a4 = $_POST['a4'][$idx]; $sql = "insert into sales (id,company, enq_num, item_desc, item_pn, item_unit, item_qty, enq_date) values (null, '$compNum','$enqNum','$a1','$a2','$unit','$a4', '$date')"; $result = mysql_query($sql); } // EndForEach segment } // End if POST ?>
  2. Thanks for reply. OK I understood, I had that in mind, but there is a problem. Lets say user wanted to have 7 rows and inside we will have 7 text fields starting with "name1" till "name7". It will be generated automatically. Problem is how to make SQL statement that will send all of them to database one by one?
  3. Hi everybody, I have a problem with function I want to store orders of each company in the database. But each company has different number of items in the order list. There is a HTML table with user defined number of rows and with text fields inside based on number of inquiries. After rows are generated name of each text field remaining the same. How can I add each text field data into my MySql database? Because there might be 1 row or 100 rows. Do you have any idea how to solve this problem? Thanks in Advance
  4. where to put it? cause I have tried to put it after each line but getting an error. So if you can, please explain. "Notice: Undefined variable: name in C:\htdocs"
  5. Hi I need help in my upload form, I don't know how to remove white space between two words if file name consist of two words. What should I put in the script below to remove the space? if (isset($_POST['btnAdd'])) { $uploaddir = 'certificates/'; $uploadfile = $uploaddir . $_FILES['file']['name']; if (move_uploaded_file($_FILES['file']['tmp_name'], $uploadfile)) { $temp = explode('/', $_FILES['file']['name']); $certificate = 'certificates/' . urlencode(end($temp)); } else { $certificate = ''; }
  6. Thank you shoz very much. It is working now.  I realy appreciate your help.
  7. Thanks shoz for reply. I have tried to run the query, but getting an error " Not unique table/alias: 'u' " Do I have to change my column names?
  8. DELETE FROM users, items, orders WHERE users.us_id = items.us_id AND items.od_id = orders.od_id AND users.us_id = '$usrID' is there anything wrong?
  9. Hi, I am new in mysql and having problem with deleting rows from multiple tables. I have 3 tables 1. table users us_id <- primary key 2. table items   od_id <- primary key   pd_id <- primary key   us_id <- primary key   it_qty 3.table orders od_id <- primary key In table "items" all are foreign keys from another tables except it_qty. The problem is when I delete user from table "user", I want delete all his records from "items" and "order" tables. My tables are in MyIsam. so far I couldn't get any valid query. Please help me with this query. Thanks in advance.
  10. still doesn't refresh, returns with an image
  11. Hi     I have a form with an image inside and delete option. When I select delete it redirects to delete.php and confirms delete if it is successful (all in php) and there is an OK button that should redirect to previous page without deleted image. I guess it possible only in Javascript but I dont know how to do it.  I tried onClick="history.back() but still  returns page with deleted image.   If you have any idea how to do it, will be highly appreciated. and sorry for my bad english.
  12. This script calls default page to the  body  of main.php  It is inside of main.php $id=''; if(isset($_GET['id'])) { $id = strip_tags($_GET['id']); } $inc = 'user/index.php'; if($id != '') { $inc = ''.$id.'.php'; } ?> this is body part of main.php <div id="content">     <?php include($inc); ?> </div> inside user/index.php i have list of users with delete button and view info. When i  select "delete" delete.php will be displayed in the body part of main.php with confirmation. To make it possible I  wrote link like  <form action="main.php?id=user/delete" method="post"> and it works with Firefox.
  13. if instead of delete.php  I use another with plain text inside it displays perfectly, I think there is some problem with  script but i don't know what problem
  14. Hi, I have problem with deleting data from mysql using php my script does work with firefox but not with IE. <form action="main.php?id=user/delete" method="post"> <td width="10%"><input type="image" src="../images/delete.gif" width="20" height="20" value="<?php echo ($row["id"]) ?>" name="delete" onclick="return confirm('Delete customer from the database?');"></td> </form> it is part of a table, inside the table I have few image buttons such as full user info, user ordered products and delete user. For each <td> I made a form, not sure whether it is correct or not, but it does work with firefox. and delete.php <?php if(isset($_POST['delete'])) { $query = " DELETE FROM user WHERE id = '{$_POST['delete']}' "; $result = mysql_query($query) or die(mysql_error()); if(mysql_affected_rows() > 0) echo 'User deleted'; } ?> Can you help me to make it work with IE?
×
×
  • 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.