Jump to content

variable in php


rashmi_k28

Recommended Posts

Hi,

 

I am new to PHP. Why the variables is used in single and double quotes when used in mysql query.

2) Is there any procedure to design the GUI for the php pages.

Please send me some of the links. How to design the php pages before implementation

 

$sql="select * from tableA where status=".$status."'";

Link to comment
Share on other sites

The example you gave should actually be (more opinion based, but it's cleaner):

$sql="SELECT * FROM tableA WHERE status='$status'";

 

As for single vs double quotes?  PHP won't parse variables inside single quotes, but will inside double quotes.  And when building sql queries, data from a variable should be enclosed in single quotes (as with $status in the example).  Once parsed, query will look like this:

 

(lets assume $status="suspended twice")

SELECT * FROM tableA WHERE status='suspended twice'

 

Without the single quotes, the query wouldn't work properly.  Hope I was clear, I'm not the greatest with explanations.

Link to comment
Share on other sites

you need to make your questions a bit clearer, but im guessing your looking for some tutorials/ resources to get you started in php?

btw for now i would leave the mysql stuff alone till you know some of the more basic stuff, refer to the above post tho

as for the GUI the gui is still developed in html, you simply use php as a way to make it more dynamic by changing variables upon either user input or other criteria,

 

one thing i will suggest is when starting out with php think of what you would like to be able to do/ achieve in the end and then narrow it down into small steps as practise really is the best tutorial (my opinion only some people will disagree),

 

here are some good resouces that you should take a look at

 

Tiztag - very basic

PHP.net - Good Reference of everything

W3schools - Good Reference of everything

 

Matt

Link to comment
Share on other sites

hi

 

Thanks for the reply. It was very informative.

I am not understanding how to design the page before implementing. Is there anu procedure to follow.

For example:Where to place a banner or how to use the frames like that.

What frameworks are normally used

Link to comment
Share on other sites

PHP is a language that takes in a bunch of variables, and outputs text (for the most part). So if you want to design a site, you have to envision the (X)HTML you want to output, then program php to output that HTML. Some people will do a whole site design first then start working on the php, well others will do the php, and then use that output and design it using CSS. It depends on your personal preference.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.