Jump to content

00stuff

Members
  • Posts

    65
  • Joined

  • Last visited

Everything posted by 00stuff

  1. Hi guys, I have an html form that gets submited to a php script that has to check if each of the form fields has information and if it does the it has to update the information on the correstponding MySQL field. The problem is that when I modify the info on one of the fields and submit the form the other fields that did not get anything typed on also get updated to nothing. I looked over my code and can't find out what is wrong. Can someone help me please? <?php $access_level = $_POST['edit_access_level']; $name = $_POST['edit_name']; $id = $_GET['id']; $password = $_POST['edit_password']; $confirm_password = $_POST['edit_confirm_password']; $today = date("m.d.y"); include('connect.php'); mysql_select_db('qcapptest'); //select database if ($name&&$access_level) { if ($password!=$confirm_password) { print '<script type="text/javascript">'; print 'alert("Passwords do not match! - Please try again!")'; print '</script>'; print '<html>'; print '<head>'; print '<script type="text/javascript">'; print 'function delayer(){ window.location = "edit_user.php?id=' . $id . ',"}'; print '</script>'; print '</head>'; print '<body onLoad="setTimeout(delayer(), 1)">'; print '</body>'; print '</html>'; die(); } $password = md5($password); if ($name != '') { $queryreg = mysql_query("UPDATE user_acl SET name = '$name' WHERE id = $id "); } if ($password != '') { $queryreg = mysql_query("UPDATE user_acl SET password = '$password' WHERE id = $id "); } if ($access_level != '') { $queryreg = mysql_query("UPDATE user_acl SET account_type = '$access_level' WHERE id = $id "); } if ($today != '') { $queryreg = mysql_query("UPDATE user_acl SET date_created = '$today' WHERE id = $id "); } print '<script type="text/javascript">'; print 'alert("Account Modified! - Click ok to go back!")'; print '</script>'; print '<html>'; print '<head>'; print '<script type="text/javascript">'; print 'function delayer(){ window.location = "view_users.php"}'; print '</script>'; print '</head>'; print '<body onLoad="setTimeout(delayer(), 1)">'; print '</body>'; print '</html>'; die(); } else { print '<script type="text/javascript">'; print 'alert("Enter all required items! - Please try again!")'; print '</script>'; print '<html>'; print '<head>'; print '<script type="text/javascript">'; print 'function delayer(){ window.location = "edit_user.php?id=' . $id . ',"}'; print '</script>'; print '</head>'; print '<body onLoad="setTimeout(delayer(), 1)">'; print '</body>'; print '</html>'; } ?> I tried changing the text in the edit_name text field and leaving the edit_password field alone but it changes also updates the password field in my database. I hope you guys can find something. Thanks,
  2. I took it out and it worked. Lol, sorry. Thanks for the help.
  3. This is the entire code but I don't see anything wrong. <?php $getinfo = mysql_query("SELECT * FROM inventory_file"); $number = mysql_num_rows($getinfo); while ($row = mysql_fetch_assoc($getinfo)) { $item_location = $row['location']; $item_description = $row['description']; $item_tag_number = $row['tag_number']; $item_highlight = $row['highlight']; if ($item_highlight == 1) { echo "<table border='1' bordercolor='black'><tr><td bgcolor='yellow'>" . $item_tag_number . "</td><td bgcolor='yellow'>" . $item_description . "</td></tr><tr>"; } else if ($item_highlight == 2) { echo "<table border='1' bordercolor='black'><tr><td bgcolor='red'>" . $item_tag_number . "</td><td bgcolor='red'>" . $item_description . "</td></tr><tr>"; } /* $getcount = mysql_query ("SELECT description, COUNT(description) AS number FROM inventory_file GROUP BY description"); while( $array = mysql_fetch_assoc($getcount) ) { echo "Description: {$array['description']} count: {$array['number']}<br>"; } */ $getcount = mysql_query ("SELECT description, COUNT(description) AS number FROM inventory_file GROUP BY description"); while( $array = mysql_fetch_assoc($getcount) ) { echo "Description: {$array['description']} count: {$array['number']}<br>"; } /* $getcount = mysql_query ("SELECT description, COUNT(description) AS number FROM inventory_file GROUP BY description"); $productcount = mysql_num_rows($getcount); echo $productcount; */ } echo "</tr></table>"; ?>
  4. Yes, I tried this: <?php $getcount = mysql_query ("SELECT description, COUNT(description) AS number FROM inventory_file GROUP BY description"); while( $array = mysql_fetch_assoc($getcount) ) { echo "Description: {$array['description']} count: {$array['number']}<br>"; } ?> I got this. Results: Description: ball count: 1 Description: shirts count: 2 Description: shoes count: 1 Description: ball count: 1 Description: shirts count: 2 Description: shoes count: 1 Description: ball count: 1 Description: shirts count: 2 Description: shoes count: 1 Description: ball count: 1 Description: shirts count: 2 Description: shoes count: 1
  5. Table Name: inventory_file Name - Type(size) id - int(11) Auto Increment location - text description - text tag_number - int(30) tag_number_2 - text letter - varchar(5) lot_number - text bin - varchar(30) time_stamp - text number_1 - int(10) number_2 - int(10) number_3 - int(10) inventory_description - text inventory_description_2 - text date_2 - text highlight - int(2)
  6. this is the inventory file, but what do you mean exact definition? [attachment deleted by admin]
  7. I tried doing something like this: <?php $product_count = 0; $getcount = mysql_query ("SELECT description, COUNT(description) AS number FROM inventory_file GROUP BY description"); while( $array = mysql_fetch_assoc($getcount) and $product_count < 3 ) { echo "Description: {$array['description']} count: {$array['number']}<br>"; $product_count = $product_count + 1; } ?> The output is this: Description: ball count: 1 Description: shirts count: 2 Description: shoes count: 1 Description: ball count: 1 Description: shirts count: 2 Description: shoes count: 1 Description: ball count: 1 Description: shirts count: 2 Description: shoes count: 1 Description: ball count: 1 Description: shirts count: 2 Description: shoes count: 1 I just want it to display it once not once for every product tha database. Does anyone know how I can fix this?
  8. This is what I did. The field containing the different products is called description. <?php $getcount = mysql_query ("SELECT description, COUNT(description) AS number FROM inventory_file GROUP BY description"); $productcount = mysql_num_rows($getcount); echo $productcount; ?> Then when I run the script I get a crazy long number 141414141414141........... I"m not sure how to get the counts with that. Can anyone elaborate please.
  9. Hi, I have a database that contains about 1000 records and one of the fielsd is called "product". There is a total of about 7 different products but the records are all mixed on the database. What I want to do is to show on the page a count of how many records of each product there are. Database Example: id - location - product - color 1 - Houston - chair - red 2 - Dallas - shoe - black 3 - Mission - chair - white 4 - Austin - tv - black This is how I want the script to display the count of products on the web page. chair - 2 shoe - 1 tv - 1 Does anyone have any idea how to check the count of each product without me having to hard code the product name on the script? The reason for that is that the data being inputed in the database will change all the time, including the product data. There might be as much as a couple of hundred different products. Thanks,
  10. could you show me how to use that with the code I already have. I tried adding it in my code and was not able to make it work.
  11. I created a html/php page that uploads a csv file to a mysql database but when I upload the file with the form it only uploads 252 lines of the document and gives me an error message on the webpage. Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'S US #1 FRONTERA FRESH U.S.A','2087658','1.11431E+11','Y','NBWLSLN132N1','ctn','' at line 1 Page with php: <html> <head> <title> Upload Inventory File </title> </head> <body> <h1>Upload Inventory File</h1> <?php include('menu.php'); ?> <?php include "connect.php"; if(isset($_POST['submit'])) { $filename=$_POST['filename']; $handle = fopen("$filename", "r"); while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { $import="INSERT into inventory_file(id,location,description,tag_number,tag_number_2,letter,lot_number,bin,time_stamp,number_1,number_2,number_3,inventory_description,inventory_description_2,date_2,highlight) values(' ','$data[0]','$data[1]','$data[2]','$data[3]','$data[5]','$data[6]','$data[7]','$data[9]','$data[11]','$data[12]','$data[13]','$data[14]','$data[15]','$data[16]','0')"; mysql_query($import) or die(mysql_error()); } fclose($handle); print "Import done"; } else { print "<form action='uploadinventoryfile.php' method='post'>"; print "Type file name to import:<br>"; print "<input type='text' name='filename' size='20'><br>"; print "<input type='submit' name='submit' value='submit'></form>"; } ?> </body> </html> All the files including the csv are on the root folder. I attached the csv file. [attachment deleted by admin]
  12. I have a computer program that gives me a list of our current inventory and I can save it to an excel file. I want to create a page that I can use to upload that excel file and then use a barcode scanner to scan the inventory on our warehouse and for the program to check the code being scanned and match it with the codes that were uploaded to the database from the excel file. Would it be possible to make the php code convert the excel file into a csv and upload it so the user doesn't have to convert the excel file to csv?
  13. I have an excel file that has several columns with different data and I need to create a form that can upload this excel file and insert the data from the columns into its conrresponding data columns in a mysql database. I know how to create the form but I have no idea how to get the file and tell it to input each cell of data into its corresponding field in the mysql database. Does anyone know how to do this? Any help would be appreciated. Thanks,
  14. Thank you, that was it. Don't know how I missed that. I can't seem to be able an set this post as resolved.
  15. I have a php page that is trying to pass a variable like this: echo "<tr><td bgcolor='white'>" . $company_id . "</td><td bgcolor='white'><a href='companyusers.php?name=" . $company_name . "'>" . $company_name . "</a></td><td bgcolor='white'>" . $company_email . "</td><td bgcolor='white'>" . $company_status . "</td></tr>"; Then when some one clicks on that link they variable with it's value should go with the url and I'm trying to assign a variable like this: $company_name = $_POST['name']; It is not working!!! I get that "Notice: Undefined index: name in 'directory of page' on line 100" Can someone help please?
  16. The site that I'm making is going to have thousands of items with pictures. Like an online store and they need to be able to be read as fast as possible and i thought that if they are included in the database in a blob field it would be easier to query and display. What do you guys think?
  17. thanks, but I don't understand what the function is doing...
  18. Hi guys, I have a problem. I need to create a page that has a web form to upload an image to a mySQL database and place it in a blob field. Then I need to be able to query the database later to display the image on the site. I've looked around but I just haven't found any examples that can help me. Does anyone know of any good example or can anyone please give me an example? I have nothing so far, just the html web form and database.
  19. Hi guys, I have this project that I'm working on. It is a simple html form that allows you to choose 5 images to upload and one of them is going to be the main image of the listing. It will also ask you for living area, name for listing, address, price, rooms, and restrooms. I need it to upload all info into a mysql database with php. I can make a simple listing with one picture uploaded but I really have no idea how to get more than one image uploaded that way I can recall them later or edit the images later. Can anyone gime some ideas please?
  20. Thank you guys. I needed some fresh ideas. I was too tired. I just didn't understand what you guys meant. I appreciate your help.
  21. // get file attributes!!!!! $photoname = $_FILES['photo']['name']; $tmp_name = $_FILES['photo']['tmp_name']; $photoname = $username . $photoname; if ($photoname) { // start upload process $location = "../userpictures/$photoname"; move_uploaded_file($tmp_name,$location); } else { $location = "../userpictures/nophoto.png"; } $queryreg = mysql_query(" INSERT INTO users VALUES ('','$fullname','$username','$password','$date','$location','$email','$phone') "); Adding that line of code changed both the file name and the location that was uploaded to the database.
  22. LMFAO!!! That doesn't change the file name... It only changes the file location. Please only reply if you really know what you are talking about. Don't worry. I found a way. Thanks anyways.
  23. Where in my script do you see "$_POST" ???? Do you have any idea of what you are saying? It's an image being uploaded. You must use "$_FILES". Show me what you mean? Write out the script from the beginning of my post with your solution. PLease.
  24. That's fine. I can encrypt the name, but what about the file? I need it to change the name of the file remember, not just the location that is uploaded to the database.
×
×
  • 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.