Jump to content

Hooch

Members
  • Posts

    452
  • Joined

  • Last visited

Everything posted by Hooch

  1. Hooch

    select from 2 tables

    Oh man, that's a better solution for me. I can understand it. I did try the 1st fix you so kindly made, but it had an error inthe table selection. I tried a cpl things, but I never got it. This last fix you made opens up countless possiblities for me too. As far as the quotes around the variables, I only go by the tutorialsI follow, or whatever I learn from kind people as yourself.I started learning PHP and mysql a cpl months ago. I have nocomputer schooling at all, just a hobby I like to play with after work. Again, thank you very much for your time and effort. Your a very generous person to devote so much time to peoplelike me. Hooch
  2. Hooch

    select from 2 tables

    I think the query is off a bit. field4 is taking the info from the limits table. The row it is taking it from is AA. (which for now is 5) Not to confuse the AA from the railcar table. (which is the entry for area)Here's the 2 tables... CREATE TABLE `limits` ( `AA` tinyint(4) NOT NULL default '1', `HMD` tinyint(4) NOT NULL default '1', `KA` tinyint(4) NOT NULL default '1', `Peroxide` tinyint(4) NOT NULL default '1', `Suva` tinyint(4) NOT NULL default '1') TYPE=MyISAM; CREATE TABLE `railcar` ( `id` int(11) NOT NULL auto_increment, `date` varchar(35) NOT NULL default '', `carid` varchar(35) NOT NULL default '', `tare` int(20) NOT NULL default '0', `gross` int(20) default NULL, `net` int(20) default NULL, `area` text NOT NULL, `commodity` varchar(35) NOT NULL default '', `inout` int(5) NOT NULL default '0', `fullempty` int(5) NOT NULL default '0', `comments` varchar(255) default NULL, PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=38;
  3. Hooch

    select from 2 tables

    Hey all. I have a need to select data from 2 tables. Here's my present code <?phpinclude '../includes/db.php';echo"<br>";$result = mysql_query("SELECT id, area, inout, COUNT(*) FROM railcar WHERE area = 'AA' AND inout = 1 GROUP BY area;")or die(mysql_error());while($r=mysql_fetch_array($result)) { $field4 = 5;$field1 = $r["COUNT(*)"]; echo "Adipic has $field1 railcar(s) onsite";echo " "; }if ( $field1 > $field4 ) {$field2 = $field4 - $field1;$field3 = $field2 - $field2 - $field2;echo " <br><b>WARNING!!</b><br>";echo "$field3"; echo " car(s) over the allotted limit!";echo "<br>$field4 is the recommended limit."; }?> Where you see "$field4 = 5;", I need the 5 to be from another table. This number can change anytime from an update page made for that reason.The table name is limits and the row I need the info from is AAThanks in advance for your help.Hooch
  4. Terriffic, Thank you very much Guy!
  5. Update, FIXED!! Wee Haa!! <?phpinclude 'db.php';$today0 = date('F d Y'); //May 07 2003$sql="SELECT id, area, carid, commodity, inout FROM railcar WHERE inout = 1 ORDER BY area ASC, commodity ASC, carid";$result=mysql_query($sql);// Count table rows $count=mysql_num_rows($result);?><table width="700" border="0" cellspacing="1" cellpadding="0"><form name="form1" method="post" action=""><tr> <td><table width="698" border="0" cellspacing="1" cellpadding="0"><tr><td width="34" align="center"><strong>Id</strong></td><td width="94" align="center"><strong>Date</strong></td><td width="183" align="center"><strong>Area</strong></td><td width="144" align="center"><strong>Car ID </strong></td><td width="237" align="center"><strong>Commodity</strong></td></tr><?phpwhile($rows=mysql_fetch_array($result)){?><tr><td align="center"><? $id=$rows['id']; ?><? echo $rows['id']; ?></td><td align="center"><input name="date" type="text" id="date" value="<? echo $today0; ?>"></td><td align="center"><input name="area" type="text" id="area" value="<? echo $rows['area']; ?>"></td><td align="center"><input name="carid" type="text" id="carid" value="<? echo $rows['carid']; ?>"></td><td align="center"><input name="commodity" type="text" id="commodity" value="<? echo $rows['commodity']; ?>"></td></tr><?php}?><tr><td colspan="5" align="center"><input type="submit" name="Submit" value="Submit"></td></tr></table></td></tr></form></table><?php// convert posted info to easy to use variables$date = $_POST['date'];//get date from form$area = $_POST['area'];//get area from form$carid = $_POST['carid'];//get carid from form$commodity = $_POST['commodity'];//get commodity from form// Below is taken from a tutorial from http://www.phpeasystep.com// Check if button name "Submit" is active, do this if($Submit){for($i=0;$i<$count;$i++){$sql1 = "INSERT INTO `daily-record` ( `id`, `date`, `area`, `carid`, `commodity` ) VALUES ( '', '$date[$i]', '$area[$i]', '$carid[$i]', '$commodity[$i]')";$result1=mysql_query($sql1);}}if($result1){header("location:daily-record333.php");}mysql_close();?> Lots of trial and error for that one, but I got it. Thanks guy!!
  6. I would like it to enter all the railcars onsite into another table.Here's my 2nd table table CREATE TABLE `daily-record` ( `id` int(4) NOT NULL auto_increment, `date` varchar(30) NOT NULL default '', `area` varchar(20) NOT NULL default '', `carid` varchar(20) NOT NULL default '', `commodity` varchar(20) NOT NULL default '', PRIMARY KEY (`id`)) TYPE=MyISAM AUTO_INCREMENT=0; With this table up to 220 railcars per day would be entered. But I have no idea how to enter more than 1 row per submit button. I tried cobbling together a tutorial for multiple updates, but it's not working. At one time I had some entry to the table. But it was entering two rows for every one that should have been there. Then it also put the word array in the fields. But that script is goen. Here is what I was working on before. (right now it isn't entering anything) <?phpinclude 'db.php';$today0 = date('F d Y'); //May 07 2003$sql="SELECT id, area, carid, commodity, inout FROM railcar WHERE inout = 1 ORDER BY area ASC, commodity ASC, carid";$result=mysql_query($sql);// Count table rows $count=mysql_num_rows($result);?><table width="700" border="0" cellspacing="1" cellpadding="0"><form name="form1" method="post" action=""><tr> <td><table width="698" border="0" cellspacing="1" cellpadding="0"><tr><td width="34" align="center"><strong>Id</strong></td><td width="94" align="center"><strong>Date</strong></td><td width="183" align="center"><strong>Area</strong></td><td width="144" align="center"><strong>Car ID </strong></td><td width="237" align="center"><strong>Commodity</strong></td></tr><?phpwhile($rows=mysql_fetch_array($result)){?><tr><td align="center"><? $id[]=$rows['id']; ?><? echo $rows['id']; ?></td><td align="center"><input name="date[]" type="text" id="date" value="<? echo $today0; ?>"></td><td align="center"><input name="area[]" type="text" id="area" value="<? echo $rows['area']; ?>"></td><td align="center"><input name="carid[]" type="text" id="carid" value="<? echo $rows['carid']; ?>"></td><td align="center"><input name="commodity[]" type="text" id="commodity" value="<? echo $rows['commodity']; ?>"></td></tr><?php}?><tr><td colspan="5" align="center"><input type="submit" name="Submit" value="Submit"></td></tr></table></td></tr></form></table><?php// convert posted info to easy to use variables$date = $_POST['date'];//get date from form$area = $_POST['area'];//get area from form$carid = $_POST['carid'];//get carid from form$commodity = $_POST['commodity'];//get commodity from form// Below is taken from a tutorial from http://www.phpeasystep.com// Check if button name "Submit" is active, do this if($Submit){for($i=0;$i<$count;$i++){$sql1="INSERT INTO daily-record ( `id`, `date`, `area`, `carid`, `commodity` ) VALUES ( id='$id[$i]', '$date[$i]', '$area[$i]', '$carid[$i]', '$commodity[$i]')";$result1=mysql_query($sql1);}}if($result1){header("location:this-page.php");}mysql_close();?>
  7. Yes. This is what I have so far. I have done more than this, but nothing is working yet. <?phpinclude 'db.php';$today0 = date('D F d Y'); // Wed May 07 2003 ?><form name="form1" method="post" action="daily-record_chk.php"><table width="252" border="0" align="center" cellpadding="0" cellspacing="0"> <td colspan="4"><div align="left"> <input type="submit" name="Submit" value="Submit" /> </div></td> <tr> <td width="72"> <input name="id" type="hidden" id="id" value="<? echo $row['id']; ?>" /> <input name="date" type="hidden" size="35" value="<? echo $today0; ?>" /> </td> <td colspan="3"><div align="right"> </div></td> </tr> <? $result = mysql_query("SELECT id, area, carid, commodity, inout FROM railcar WHERE inout = 1 ORDER by area, commodity, carid ASC;")or die(mysql_error()); while($row=mysql_fetch_array($result)) { ?> <tr> <td> <input name="area" type="text" id="area" value="<? echo $row['area']; ?>" size="12"> </td> <td colspan="2"> <input name="carid" type="text" id="carid" value="<? echo $row['carid']; ?>" size="18" /> </td> <td width="72"> <input name="commodity" type="text" id="commodity" value="<? echo $row['commodity']; ?>" size="12" /> </td> </tr> <?php } mysql_close(); ?></table></form> I am having a problem with the daily-record_chk.php (line 5) I'm at work right now, if you like I can post that code tonight after 9PM. Maybe it only needs a tweaking. But please let me know if I have this posted code correct. I can tell you it query's the info perfect. thanks..Hooch
  8. Is this possible? I want to be able to enter all the railcars we have onsite everyday. The database will have over 1000 railcars, but we may only have 200 onsite.So I have made a query for only onsite cars. Now is it possible to have thisquery updated eveyday with a form, or what would be the best way. If this is possible. Thank you.
  9. Could someone please let me know what is wrong here?? if(strlen($firstname) + strlen($lastname) > 20){//errordie("Too many characters. Please use an intial for the 1st name.<br>Hit your <b>Back</b> button to save the data,<br>Or <a href=\"admin.html\" target=\"_parent\">click here</a>");} The entry still goes to the database with 21 characters. Thanks.. Hooch***EDIT*** Sorry, I found my error. All is well...Thanks for looking though
  10. Hey everyone. I want to have a marquee that's editable from a webpage. So far I can enter the words, and they show up. I also have made another script to update the existing field. The problem is there will be a 2 step process in getting the marquee started, then updated. Is it possible to only have 1 entry field (on the webpage) for the 1st entry, and every change after? I know this would be possible If I made the table, then manually entered something via mysql. Then I would only need to update the field. But is there a way around this so the user can do it themselves? (via the webpage) I hope this is clear..thanks Hooch P.S should I make it so only 1 field can enter this table? I only want 1 entry for this table anyway. If so, how would this be done??
  11. Hooch

    problem with $id

    Sorry for the confusion, (and I'm not trying to be smart here)but in my 1st post I said I was connecting to the existing phpbb forum. So I need to have that user_id somewhere correct? I want the members of the forums to log into the main page with the forum settings. This way they do not need to create 2 accounts. I have a knack for asking confusing questions. I hope you understand now.
  12. Hooch

    problem with $id

    To clarify, the default phpbb users_table has an id of"user_id" This is why I'm mentioning it. So to reference it shouldn't the above code have it there?
  13. Hooch

    problem with $id

    I'm a bit confused guy.Should'nt there be $user_id somewhere??
  14. Hooch

    problem with $id

    Hey there everyone. I am trying to connect to my existing phpbb database from my main webpage. I had a usersytem set up and working, but my id in the old database was named just that, "id". But phpbb names it's id "user_id". My problem is I'm not sure what I need to change here. // get users id$getid = "SELECT * FROM my_table WHERE username='".$user."' LIMIT 1";$getidexec = mysql_query($getid);while($r=mysql_fetch_array($getidexec)){$id = $r[id];}// set a cookiesetcookie( "id", "$id", time()+3600, "/", "", 0 ); Here's what I changed it to.. // get users id$getid = "SELECT * FROM my_table WHERE username='".$user."' LIMIT 1";$getidexec = mysql_query($getid);while($r=mysql_fetch_array($getidexec)){$id = $r[user_id];}// set a cookiesetcookie( "id", "$user_id", time()+3600, "/", "", 0 ); If this is correct, I can move on to other solutions. Thank you..Hooch
  15. Hi everyone. I have made a few forms now and each time I have a similar problem. When you tab to the text area you want to enter the info, the cursor will betowards the middle of the box. If you enter the info without moving the cursor to the top left of the box, it entersthe info into the database with all those spaces. How would I fix this??Thank youHooch
  16. Hooch

    subtract from a form

    Cha ching! Thank you.
  17. Hooch

    subtract from a form

    It displays the info perfectly. When I say print..I mean actually print out the data on a printer. I was hoping to have a button on that "if($result){ success part"So a simple click could print my data out. And thank you very much for your input guys.
  18. Hooch

    subtract from a form

    Sure thing man. The end of the script there's a table. Everything inside it... <?phpinclude 'db.php'; $net=$_POST['gross']-$_POST['tare'];$sql="UPDATE railcar SET area='$area', carid='$carid', tare='$tare', gross='$gross', net='$net', commodity='$commodity', inout='$inout' WHERE id='$id'";$result=mysql_query($sql);if($result){include 'db.php';$today0 = date('l dS \of F Y h:i:s A');// Prints something like: Monday 15th of August 2005 03:12:46 PM $result = mysql_query("SELECT * FROM railcar WHERE id='$id';");while($row=mysql_fetch_array($result)){?><table width="300" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="4"><? echo $today0; ?></td> </tr> <tr> <td height="40" colspan="4" valign="bottom"><div align="left"><? echo $row['carid'];?></div></td> </tr> <tr> <td width="51">Tare</td> <td width="67"><div align="right"><? echo $row['tare'];?></div></td> <td width="47"> kg's</td> <td width="135"> </td> </tr> <tr> <td>Gross</td> <td><div align="right"><? echo $row['gross'];?></div></td> <td> kg's</td> <td> </td> </tr> <tr> <td>Net</td> <td><div align="right"><? echo $row['net'];?></div></td> <td> kg's</td> <td> </td> </tr> <tr> <td><a href="list_records.php">Update</a></td> <td><a href="index.php">Home</a></td> <td> </td> <td> </td> </tr></table><?}}else {echo "ERROR";}?> Pretty much the if($result){ success part. Thanks Dan!
  19. Hooch

    subtract from a form

    I think so. Everything is working so far. I even was able to redirect to a page that shows the recently updated info. Now off to google to see how to print my results!! Thank you everyone!!
  20. Hooch

    subtract from a form

    Ah Ha! I changed$net=$_POST['gross']-$row['tare'];to$net=$_POST['gross']-$_POST['tare'];and it worked!! Even though the tare is in the DB I figured it still is getting posted. So what the hay.
  21. Hooch

    subtract from a form

    I'm getting close. All fields are getting updated, but the net filed is updated with the tare. It's not the calculation result.Here's my update_chk.php <?phpinclude 'db.php';$net=$_POST['gross']-$row['tare'];$sql="UPDATE railcar SET area='$area', carid='$carid', tare='$tare', gross='$gross', net='$net', commodity='$commodity', inout='$inout' WHERE id='$id'";$result=mysql_query($sql);if($result){echo "Successful";echo "<BR>";echo "HAVE PRINT OUT HERE";}else {echo "ERROR";}/* reportingsjr's help$net=$_POST['gross']-$row['tare'];$query="INSERT INTO `table name` ('name of net column') VALUES ('" . $net . "')";$result="mysql_query(query);*/?> When I add the VALUES ('" . $net . "')"; it causes errors. I know you didn't mean for it to go where I am putting it now. Would you mind having a boo?
  22. Hooch

    subtract from a form

    Here's my existing query (above that posted code) <?phpinclude 'db.php';$sql="SELECT * FROM railcar WHERE id='$id'";$result=mysql_query($sql);$rows=mysql_fetch_array($result);?> I'm thinking the code you posted needs to be in my form's action.This form is called update.php. Then the action is sent to update_chk.php. I'll have to rethink my structure here. I need to be able to prinout the net weight. So maybe after the update_chk.php has added the info to the database I'll redirect to a page that displays the new calculation made. And just have a print button there. I'll update on my progress. Thanks lad!!Hooch
  23. Hooch

    database layout

    heheThanks pulp..I did that. It's comming along well. I have a php question regarding subtraction. I posted it in the php section. This is fun stuff. Almost done!!
  24. Hooch

    subtract from a form

    Hey there! I am wanting to get the net wieght of a rail car through a form. I will have the tare wieght in the DB. The gross wieght would be entered in by the user. Now once the gross weight is entered, is it possible to update the database with the net weight with the click of a button? I have no idea how to make the calculation. The following code is what I have so far. I am able to update the database before this net weight issue. <td align="center"><strong>Area</strong></td><td align="center"><strong>Car ID</strong></td><td align="center"><strong>Tare</strong></td><td align="center"><strong>Gross</strong></td><td align="center"><strong>Net</strong></td><td align="center"><strong>Commodity</strong></td><td align="center"><strong>Onsite</strong></td></tr><tr><td><input name="area" type="text" id="area" value="<? echo $rows['area']; ?>"></td><td><input name="carid" type="text" id="carid" value="<? echo $rows['carid']; ?>"></td><td><input name="tare" type="text" id="tare" value="<? echo $rows['tare']; ?>"></td><td><input name="gross" type="text" id="gross" value=""></td><td><input name="net" type="text" id="net" value="<? WHAT GOES HERE?>"></td><td><input name="commodity" type="text" id="commodity" value="<? echo $rows['commodity']; ?>"></td><td><input name="inout" type="text" id="inout" value="<? echo $rows['inout']; ?>"></td></tr><tr><td><input name="id" type="hidden" id="id" value="<? echo $rows['id']; ?>"></td> I thank you in advance...and I hope it can be done.Hooch
  25. Hooch

    PHP NUKE

    Here's a possible fix..From Nuke ResourcesPosted by diveanx
×
×
  • Create New...