Jump to content

billgod

Members
  • Posts

    28
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

billgod's Achievements

Member

Member (2/5)

0

Reputation

  1. I hope this has never been answered before but I don't even know what to look for.. here is what I am doing. database is doing a select to grab all names in db and putting checkbox next to them. checkbox value is the id - unique key echo "<tr><td><input type='checkbox' name='$rows[id]' value='$rows[id]'></td> <td> $rows[col_name]</td></tr>"; when I submit the form.. I need to find all that have check boxes and update the database. How can I do this without having to do if ($_POST[2]==2) or some crazy thing like that. anyone out there know an EASY way to do this? yes I suck as a coder but this is for personal stuff not for a enterprise type site.
  2. EXACTLY what I was looking for ... Thanks a million.
  3. I have a datetime table in my db. my time stamps look like this 2011-09-28 16:34:03 My question is this If I have a time in of 2011-09-28 10:34:03 and a time out of 2011-09-28 18:04:03 how can I figure out the hours worked? Any help is appreciated.
  4. exactly what I needed.. Thanks!
  5. I am creating a site that has to display 36 images on the screen. The image name is stored in the database. My problem is if I have less than 36 images stored I need to display a default image. here is my current query $sql="SELECT col_image, col_url from tbl_images WHERE col_active='1' and col_bigimage='0' ORDER BY RAND() limit 36"; so If I only have 20 active images. I need to display 16 default images. I hope this makes sense. Bill
  6. Here is my query I currently have $sql2="insert into tbl_orders (col_orderid, col_prodid, col_qty) values ( '$orderid', '$row[id]', $_POST[number])"; $result2=mysql_query($sql2) or die ('Error: '.mysql_error ()); I need to be able to insert $_POST[22], $_POST[54] and so on. I am not sure how your suggestion is going to accomplish this. I need $_POST[number] to change with every loop.
  7. If I knew what to call it I could have searched it. So I will just explain. I have a form that is pulling from a database to build the following. echo <input name='$row[id]' type='text' id='$row[id]' size=2>; This will build a page that has this <input name='22' type='text' id='22' size=2> <input name='54' type='text' id='54' size=2> This part works great. The problem is when I try to add it to the database. How can I insert variables that I don't know the names of? They will be something like $_POST[22] $_POST[54] and so on. I hope someone can understand my jibberish. I am sure there is a WAY better way to do this.
  8. This is for a ticket system I wrote for my small computer repair shop. The col_techcomments type is set to LONGTEXT in MYSQL. for example. The first comment may say something like "tested hard drive. Drive failed" I can use my form on the web to pull the data out of the database and display it on my screen. I can then modify it and hit save. Then look at that ticket again and all my changes are there. I am trying to add a new feature that when I order a part, adds the part, price and where I purchased it to a new table. This part works also. I then want it to take the part, price and where I purchased it and append it to the current col_techcomments. This is the part that does not work. It should now say "tested hard drive. Drive failed Parts ordered - Hard drive, 63.17 from Newegg.com" If I echo my sql query to the screen. Then copy and paste it into phpadmin. the query runs and updates the table with no errors but will not do it by itself. It's almost like its skipping the query but I know its not since I purposefully added typos just to see it fail and it does. I know its not adding it because I am looking at the table in phpadmin and it shows exactly what it did before I run the script.
  9. That is a copy and paste of the code. like I said before If I change the query with a typo on like table name. mysql spits out an error of no table found. Just like this has no errors at all. I just tried changing my query to $sql12="update tbl_ticket set col_techcomments='blahblah' where id = 830"; and it did not update my table to blahblah??
  10. concat does not seem to do what I need. Lets say for instance I have this in my database fish I need to add the word tank (that is not in the database) to fish to get Fish tank So the only way I know to do it is query for fish. use php to concat my second string and update the database. You ask how I know its not working? When I look at the table the data stays the same. Check this out.. If I copy and paste the entire update query into another php page. It works?? WTF?
  11. If I just do an update. Won't it erase what is already in there? I need to append this to the data in the same column. var_dump shows string(3) "830" I tried using session and post thinking that was the problem so my code may have both versions floating around in it.
  12. var_dump show string(3) "830" which 830 would be the correct ticketid in this case. The sql query that gets echoed is update tbl_ticket set col_techcomments='Ordered Parts test 123.12 From:test ' where id = 830
  13. Anyone have any idea why this is not wokring? if ($_POST[partsyes] == 'yes'){ $sql10="insert into tbl_partsordered (col_ticketid, col_price, col_orderedfrom, col_part, col_date) values ($_SESSION[ticketid], '$_POST[pprice]', '$_POST[pfrom]', '$_POST[part]', CURDATE( ))"; $result10=mysql_query($sql10) or die ('Error: '.mysql_error ()); //get tech comments so we can add our parts ordered to them. $sql11="SELECT col_techcomments FROM tbl_ticket where id = $_SESSION[ticketid]"; $result11=mysql_query($sql11) or die ('Error: '.mysql_error ()); while($row11 = mysql_fetch_array($result11)) { $newtechcomments = $row11[col_techcomments] . " " . "Ordered Parts" . " " .$_POST[part] . " " .$_POST[pprice] . " " . "From:" .$_POST[pfrom] . " ". $today; $sql12="update tbl_ticket set col_techcomments='$newtechcomments' where id = $_POST[ticketid]"; $result12=mysql_query($sql12) or die ('Error: '.mysql_error ()); } } The first query pull data out of the database. then concatenates that string with other strings. The update query never runs? If I add echo $sql2; and copy the sql that is displayed on the screen and paste it into phpadmin it updates just fine. I tried putting a typo in on the query just to see if it failed. It does. so I know its running the query This is driving me nuts. I know it's gotta be a typo somewhere. Also don't make fun of my code.. I know It's gotta be bad.
  14. that just made it blow up.. ok figured out a little more. It's updating the wrong table row? if I echo my $_POST[ticketid] it is correct. If I echo the SQL statement it is correct. But if I let it run. It seems to updating rows starting with id 1 then 2 then 3 and so on? here is the SQL statement that gets generated UPDATE tbl_ticket set col_techcomments=' Left VM Fri, 30 Apr 10 14:22:06 -0400' where tbl_ticket.id = 670 If I paste this into mysql it works perfect?
  15. if (isset ($_POST[callcust])){ // Connect to server and select databse. mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("cannot select DB"); //get todays date and set format $today = date(DATE_RFC822); //grab old comments from db $sql=" SELECT col_techcomments FROM tbl_ticket where id = $_SESSION[ticketid]"; $result=mysql_query($sql) or die ('Error: '.mysql_error ()); while($row = mysql_fetch_array($result)) { // combine old comments with time stamp $newtechcomments = $row[col_techcomments] . " " .$_POST[callcust] . " " . $today; //update DB mysql_query("UPDATE tbl_ticket set col_techcomments='$newtechcomments' where id = $_POST[ticketid]") or die ('Error: '.mysql_error ()); } } If i echo my update to the screen. The update sql looks correct. If I copy and paste it into mysql it runs and works fine. It's like php is just skipping th update. PS I am in no way shape or form a software developer. If my code looks like crap thats why.
×
×
  • 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.