473,387 Members | 3,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

drop down menu list update *help*

201 100+
i can query the list fine using:

Expand|Select|Wrap|Line Numbers
  1. select list.list, many_table.list_id_fk from list left join many_table
  2. on list.id = many_table.list_id_fk and many_table.userid = 'UserId';
  3.  
that populates the list per user id.

now when the user selects a new item from the list
it does not update

here is the update query:
Expand|Select|Wrap|Line Numbers
  1. $updateSQL = sprintf("UPDATE list_many SET list_many_id_fk=%s, UserIdFk='1', `Date`=now() WHERE Id=%s",
  2. GetSQLValueString($_POST['list_many_idfk'], "int"),
  3. GetSQLValueString($_POST['UserIdFk'], "int"),
  4. GetSQLValueString($_POST['Date'], "date"),
  5. GetSQLValueString($_POST['Id'], "int"))
  6.  
thanks in advance for your help!

theo
Sep 23 '09 #1
7 2677
TheServant
1,168 Expert 1GB
Can I just ask why you are using that method to update your tables? Why haven't you used something like:
Expand|Select|Wrap|Line Numbers
  1. $list_many_idfk = $_POST['list_many_idfk'];
  2. $userIdFk  $_POST['UserIdFk'];
  3. $date  $_POST['Date'];
  4. $id = $_POST['id'];
  5.  
  6. $result = mysql_query("UPDATE list_many SET list_many_id_fk=$list_many_id_fk, UserIdFk='1', `Date`=now() WHERE Id=$id");
I think that's much easier to read/debug etc... As I say, I don't know much about this method, but are you sure you can set default values for UserIDFk and Date?
Sep 23 '09 #2
Dormilich
8,658 Expert Mod 8TB
in sprintf() there are only the indicated values (%s, …) replaced, you have 2x %s but 4 values, obviously, the last two are therefore not used.
Sep 23 '09 #3
wizardry
201 100+
no problem neither did i, until i started programming it and using it. that method ( GetSQLValueString) calls a function which checks for sql injection, etc... you can log it if it fails, suspects, etc...

I prefer this method. less issues in the long run.

yes you can changed the %s to include a default record to set that should be in the where i switched them around. not worried about id. just the users record that is being updated.

************************************************** *********

ok -

this is what i'm trying to do.

pull data from a list table, for the fk in the many table and allow the user to update by using the drop down menu.

i have the drop down menu pulling the records and defaults on the record stored in the many table. its just the update is failing.

any help is appreciated.

ive tried doing a join update which works in mysql but php doesnt like it.
Sep 23 '09 #4
Dormilich
8,658 Expert Mod 8TB
@wizardry
this should be no concern of PHP since it is only a string. if PHP doesn’t like it, there should be at least an notice/warning/error message.
Sep 23 '09 #5
TheServant
1,168 Expert 1GB
@wizardry
Interesting, thanks. Well because I don't know the function myself, and for the next 8 hrs I will not be able to test it out, I recommend you do this:
Make a simple MySQL query (using GetSQLValueString) and bit by bit add small components to change it in your code until it doesn't work - that will be your problem, or atleast one fo them. It's the long way round, but I think you will get a result quicker.

Failing that, wait until another expert comes along to this post and spots it without reading twice :P
Sep 23 '09 #6
wizardry
201 100+
this has been resolved!

i needed to limit what the form was updating, just the list fk id and date that the new update was entered.

Expand|Select|Wrap|Line Numbers
  1. $updateSQL = sprintf("update ASBodyType as a
  2.               left join BSType as b
  3.         on b.Id = a.BodyType
  4.         set a.BodyType=%s, a.Date=now()
  5.              where a.UIdFk='1'",
  6.            GetSQLValueString($_POST['BodyType'], "int"));

thanks again for your help!
Sep 24 '09 #7
TheServant
1,168 Expert 1GB
Your code looks a little different with the BodyType, so still unclear what the problem was, but glad you got it solved.
Sep 24 '09 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: vikram.cvk | last post by:
Hello Experts, Im trying to design a CSS vertical drop down menu which should have the following functionality. Home About Us | -->Overview
2
by: hemanth.singamsetty | last post by:
Hello there, I've a drop down menu (created using CSS & Javascript -- see code below). My problem is, whenever I click a link on the menu the new page replaces the current page (and the menu...
17
by: Aussie Rules | last post by:
Hi, I want to have a single line combo box dropdown, but where i can selected multiple items in the drop down via a check box... I can see one in the standard tool box... is there one ? If...
1
by: StevePBurgess | last post by:
Hi I am using a drop down menu adapted from the one in Stylin with CSS by Charles Wyke Smith. The CSS is below. It works perfectly in Internet Explorer (using the csshover behaviour file) but...
4
by: Laura K | last post by:
I have a drop down menu which has a list of subcategories and the initial value is "please choose a Subcategory". When the user chooses a subcategory they are taken to a new page where the drop...
0
by: weiwei | last post by:
Hi here is my scenario, I create a drop down list in itemtemplate.(that drop down is created from db), after user click edit command, my ideal plan is have another drop down list in...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
3
by: SQLjunky | last post by:
Hello, Contrary to what my screen name indicates, i'm actually quite new to SQL. Having said that, I'll get right into my problem. I'm trying to query an mssql database to return to the value...
22
by: Archanak | last post by:
Hi, I am using 2-level CSS Drop Down Menu in my perl/CGI program. here is the code. #!c:/perl/bin/perl.exe use CGI qw(:standard);
7
by: wizardry | last post by:
hello - i've created a drop down menu in dreamweaver, it selects my states from a list table that i have for users table. I went from enum to list table and created a fk to the parent table. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.