Jump to content

Do i need to change variable?

Recommended Posts

Hello. Stupid question here.

So when i write sql code inside variable, do i need to change it (the variable) everytime or will php be able to see to difference? Lile this:

$sql = "select * from users"

$result = execute sqk here...

$row = output here.. fetch data...

$sql = "select * from stars"


And so forth? Or do i need to change the variable everytime so php can know each different sql code and fetches everytime?

Thx in advance..

Ps: writing from a cellphone, sorry if i dont deliver perfect info, so hope you understand the question :P

If not, ask and ill retype the question when home later tonight at my laptop :D

Thanks a lot :D


Link to post
Share on other sites

Whatever the predefined variable value is at the time php code refers to that variable is what is used. if $result refers to $sql variable the value will be and show 'select * from users',  if the $result was after the last $sql, this last $sql overwrites the previous variable to show  "select * from stars".

If that is what you are asking?

  • Thanks 1
Link to post
Share on other sites

Perfect.. it was the exactly answer i wanted :D

Link to post
Share on other sites

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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