April 10, 2012

Only update fields that are not null

Question by user1325305

I have been trying to figure out how to update the fields only if they are not null (otherwise NULL overrides the unchanged fields). It doesn’t matter that the fields can not be null.

I have tried both the COALESCE and ISNULL, however I must not be using them in the right way as I’m not use to the Dreamweaver coding. The code is below:

<i>if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "catalogue")) {
  $updateSQL = sprintf("UPDATE catalogue SET catbox1=%s, catbox2=%s, catbox3=%s, catbox4=%s, catbox5=%s, catbox6=%s WHERE id=%s",
                       GetSQLValueString($_POST['catbox1'], "text"),
                       GetSQLValueString($_POST['catbox2'], "text"),
                       GetSQLValueString($_POST['catbox3'], "text"),
                       GetSQLValueString($_POST['catbox4'], "text"),
                       GetSQLValueString($_POST['catbox5'], "text"),
                       GetSQLValueString($_POST['catbox6'], "text"),
                       GetSQLValueString($_POST['id'], "int"));</i>

Answer by Starx

There are few mistakes in you code, But these can be typos.

  1. NO PHP Wrapper: You have include your mysqlcode with portion
  2. Use IS NOT NULL instead of ISNULL

Basic way of what you are trying to do is use a query like this

UPDATE `tablename` SET `fieldName` = 'value' WHERE `fieldName` IS NOT NULL
June 8, 2011

Where do i begin programming in php?

Question by angel

i am a programer i have programed in C#, asp.net, Visual basic, Java, j2me, and now i want to learn php, i downloaded dreamweaver i choosed php
and i watch only code html i dont know how to put textbox, radiobutton, and more controls, in the another (not java) i choose the control and i move it… it is easy doing it, of this form, i didn’t see nothing as this, in dreamweaver, another question, how do you add class in php? for a programing OO …
add clases and methods (in php i believe they are called functions)
if dreamweaver is bad, what program do you recommend me?

Answer by itsols

Yes, you can use DreamWeaver for PHP development. But don’t expect the same ‘look and feel’ of IDEs like MS C# or VB.

For example, you can create your forms in design view on DreamWeaver by dragging elements onto it, and then add the code by going into code-view. I don’t recall the actual wording used on DreamWeaver but there’s one view with a designer and the other with HTML code.

For example, if you create a textbox on the form, the code behind it will be something like this:

<input type="text" name="txtEmployeeID" />

Now, if you want to print some variable from within the code, you could include it in the code view like this:

<input type="text" name="txtEmployeeID" value="<?php echo $EmployeeID; ?>" />

You can actually incorporate PHP code within the html page simply by enclosing the code within the php tags like above.

But this is only a very elementary example. You can actually use ANY editor and what you use would also depend on the OS you have. For example, on Ubuntu I use GEdit, with a few plugins that help easily read PHP code using a nice colour scheme. But for a beginner, this may not be the ideal thing.

I don’t mean to advertise myself, but I have a simple video of GEdit in use on YouTube. If you’re interested, you may check it out on my channel “marhaonline”.

Answer by Starx

My recommendation will be going with Zend Studio. It is developed especially for PHP Development, where as others, are created for multiple purposes.

Did I mentiond It is also an award winning IDE also?…
Check Here


You are also asking about putting textbox, and radio buttons. This is more HTML based, rather than PHP, if this is major concern then, it should go with netbeans or dreamweaver, they provide better and user friendly UI for this.

In the latest dreamweaver,
There is a panel called Insert Panel (Ctrl + F2 on Windows), it gives all the HTML elements, including form elements (Just select “FORM” from the drop down box”), which you can also drag and drop.

...

Please fill the form - I will response as fast as I can!