Jump to content

medj

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

medj's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have 2 tables called 'components' and 'bom'. My 'components' table has 10 columns. (~100 rows) My 'bom' has 6 columns. (~12 rows) There is one column in the 'bom' table that has same value as one of the columns in the 'components' table. I would like to match this 'bom' column against the component column. I do know how to do this already with a query such as the following: SELECT `components`.`part_num`, `components`.`name` FROM `components` WHERE `components`.`part_num` IN (SELECT `bom`.`number` FROM `bom`) This is my problem that I am facing: I would like to be able to display all column data on the page. For example, I have 10 + 6 = 16 columns of data from both tables. I would like to display all the data from both tables. I already know the php code to display data from rows. For instance, I am able to display the 'part_num' and 'name' of all the components table for the 12 rows of the 'bom'. I can add more of these if I wanted to show the 10 rows from the components table. The main problem is that I would like to display the other 6 columns of data from the 'bom' table and I have tried many different alternations of the query but can't seem to make it work. Any help please?
  2. Hi everyone, hopefully there is an easy solution to my problem. I have spent the better part of the day trying to get my script to work. I have gotten pretty far but have just hit a fork in the road. Let me explain: I have a database and I list all the rows of the table with a checkbox on the left of each row. The checkbox is mainly an indicator whether that item (row) is important or not. So basically I created a checkbox array. Here is a part of my code: <input name='track_stock[]' type='hidden' value='off'><input name='track_stock[]' type='checkbox' value='on' " . ( ($row[trackstock] == 'on') ? " CHECKED" : "") ."> You will notice the hidden field that appears before the checbox. I had to search forever to fix that first problem where I found out only checkboxes that were checked were being sent with the form. The problem I have now is that the checkbox values are being sent twice for each row. Once for the hidden value and one for the checkbox value. So my checkbox values go into the database as either 'on' or 'off'. Just to tell you an example, if I select the first checkbox and click submit I get: off on off off off off.... If I select the first two, I get: off on off on off off off off... Maybe there is an easier way to do this. Anyone can help me please?
  3. Okay, I have been working on this for the past 2 hours and I think I actually was able to get pretty far. It is still not working though, I was hoping someone could take a look at my code below and let me know what is wrong. I will paste some of the important parts. <form name="form1" method="post" action="display.php"> ... while ($rows = mysql_fetch_array($match_query)) { $id[] = $rows['part_num']; ... <td class="<? echo $color; ?>"><input name="stock[]" type="text" id="stock" size="5" value="<? echo $rows['stock']; ?>"></td> ... <input type="submit" name="Update" value="Update"> ... if (isset($_POST['Update'])) { for($i=0;$i<$count;$i++){ print $id[$i]; $update_stock = mysql_query( "UPDATE components SET stock='$stock[$i]' WHERE part_num='$id[$i]'" ) or die("SELECT Error: ".mysql_error()); } } if($update_stock){ header("location:display.php"); } mysql_close(); I want to be able to change as many stock values as I want and then click update at the bottom in which the page will be refreshed with the new values and the message "Database updated" or something like that. You can see my results by clicking http://eldoled.blankevolution.com
  4. But somehow I need a button at the end that will UPDATE all values of any rows I happen to edit.
  5. I have a column called "Stock" of one of my tables which has an integer value. I have many rows in my database and what I want to do is create a page which will give an input box with all the stock values for me to be able to update. Well in fact, I have already did this much, in terms of showing the input box with the value of the stock being displayed inside. What I want is a "Update All" Button at the bottom when clicked will update all stock values that I change on the page. Any help is greatly appreciated.
  6. I am trying to implement a way to edit one piece of data in a row from my database. If you can take a quick look at: http://eldoled.blankevolution.com/. Select "Match" and then any of the 3 sub options on the right. When you click submit, you will get a page that displays many rows where the stock is listed on the right. The plan is to be able to click the Edit Link on the right and be able to edit the 'stock' value. When you hover over the edit links you will notice that the 'id' is set to the part number and it is being sent with the submit. Now the problem I am having is being able to display an edit box that will let me edit the stock of the part that I click on. Here is some of my code: The Edit Link <a href='display.php?cmd=edit&id=$get_info[1]'><b>Edit</b> - $get_info[1]</a> The query to get the required part to edit: $id = $_GET["id"]; $edit_row = mysql_query( "SELECT components.part_num, components.stock FROM components WHERE components.part_num=$id" ) or die("SELECT Error: ".mysql_error()); $myrow = mysql_fetch_array($edit_row); And just in case this might help, this is the error when I click the Edit link: SELECT Error: Unknown column '10MQ100NTRPBF' in 'where clause' The "10MQ100NTRPBF" is replaced with the part number of the link I click. Can anyone please help?
  7. Thanks for the reply. I gave that example as I thought there was someway to just show all the values that are not part of your query. This is what my code really looks like: $function_match = mysql_query( "SELECT components.manufacturer, components.part_num, components.stock FROM components JOIN $bod ON (components.part_num=$bod.manufacturer_num)" ) or die("SELECT Error: ".mysql_error()); $function_no_match = mysql_query( "SELECT components.manufacturer, components.part_num, components.stock FROM components JOIN $bod ON (components.part_num!=$bod.manufacturer_num)" ) or die("SELECT Error: ".mysql_error()); The only difference between both of them is that the second one gets all the ones that the first one didn't get. You can actually see what I am trying to do if you go to http://eldoled.blankevolution.com. Select the radio button match and then click submit. You will see the colored boxes on top which are the matches and then the rest are suppose to be the non matches. For some reason I'm getting a weird result where it seems to be showing each of my non matches 8 times.
  8. I was just wondering if there was an optimal way to display the results of a query as well as the anti-results if you know what I mean. $query = mysql_query( "SELECT * FROM table WHERE `table`.`age` > 20" ) So I would first display the results where the age of the person is over 20. But underneath the information, I would like to display the people whose age is under 20. Is it just a matter of making a $query2 where the age < 20 and display it? Or is there a more better way to do this.
  9. Hopefully someone can help me out with this. I have a database with 2 tables. I simply would like to perform a query that will display the rows where the "Part Number" of the first table matches the "Manufacturing Number" of the second one. This works out fine for me since I'm using this code: $function_match = mysql_query( "SELECT * FROM components, bom_dimwheel_white WHERE `components`.`part_num` = `bom_dimwheel_white`.`manufacturer_num`" ) or die("SELECT Error: ".mysql_error()); I have about 20 column/fields in "components" and 10 in "bom_dimwheel_white". When I display my results of the query, I am getting all 30 fields being displayed when all I want is to show the results of the components table. What I mean is that the display should only have the 20 field columns from the 'components' table. Can anyone help me out?
  10. Thanks so Much  ;D You just saved me tons of time. Maybe you can tell me what you think of my site: http://blankevolution.com
  11. by default, my script request MYSQL information from a database. The line I need help with is: LIKE '$c' I have a number of categories on my site that use the variable $c In this mysql line, i dont want to grab info from the database with variable $c but with the variable $c + the word 'media' on the end of it. I've tried doing                  LIKE '$cmedia'        doesnt work obviously since $cmedia is a whole new variable entirely. I've tried              LIKE '$c+media'        doesnt work Please anyone?
×
×
  • 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.