Jump to content

Basic Php


MaisieWebster

Recommended Posts

Hi can someone help me, im new to php and was wondering what the structure of a php code would be for this question?

 

 

 

write some PHP code to read the artist that the user entered into a variable, $a. After reading in the artist, write some PHP code to display a message which tells the user what artist they enteredNotepad write some PHP code to read the artist that the user entered into a variable, $a. After reading in the artist, write some PHP code to display a message which tells the user what artist they entered

 

I am so confused and have to get this done by monday!!

 

Thanks :)

Link to comment
Share on other sites

Leaving it a bit late arn't you? Who the hell gives out courcework that encourages people new to PHP to use single letter variable names? That's almost as stupid as Barand constantly giving people on here, that are new to MySQL, code that has nonsensical, irrelivent and unnescesary single letter table aliases.

 

Anyway.

 

What part is confusing? The logic or the code? Have you tried to come up with a solution already? How much do you know about HTML and Form elements? how many pages are you to use (1 or 2)?

Link to comment
Share on other sites

Hi can someone help me, im new to php and was wondering what the structure of a php code would be for this question?

 

 

 

write some PHP code to read the artist that the user entered into a variable, $a. After reading in the artist, write some PHP code to display a message which tells the user what artist they enteredNotepad write some PHP code to read the artist that the user entered into a variable, $a. After reading in the artist, write some PHP code to display a message which tells the user what artist they entered

 

I am so confused and have to get this done by monday!!

 

Thanks :)

 

Just build a form that lets the user enter some data into a text area, and catch the information in a variable. Then echo the variable. Very simple to do, you could learn how to do it with a quick tutorial.

Link to comment
Share on other sites

Leaving it a bit late arn't you? Who the hell gives out courcework that encourages people new to PHP to use single letter variable names? That's almost as stupid as Barand constantly giving people on here, that are new to MySQL, code that has nonsensical, irrelivent and unnescesary single letter table aliases.

 

I would have thought best place for your piece of puerile trolling was in response to one of my "nonsensical" posts, not here. At least my queries are relevant to the topic.

 

Aliases are useful and, at times, necessary. Perhaps you feel that the alias, if any, should be at least as long as the original table name. My use of them is totally legitimate, in stark contrast to your spelling. If you want to expose to the world your illiteracy in both English and SQL, feel free. But don't do at my expense.

Link to comment
Share on other sites

Leaving it a bit late arn't you? Who the hell gives out courcework that encourages people new to PHP to use single letter variable names? That's almost as stupid as Barand constantly giving people on here, that are new to MySQL, code that has nonsensical, irrelivent and unnescesary single letter table aliases.

 

Anyway.

 

What part is confusing? The logic or the code? Have you tried to come up with a solution already? How much do you know about HTML and Form elements? how many pages are you to use (1 or 2)?

 

1. One character variable names aren't inherently bad. Variable names should give an indication of the data the variable carries, but there's no length requirement. Is $i confusing in a for-loop? Is $a confusing in a small script where it's the ONLY variable in that script and is assigned to an artist's name? I'd much rather see that than a slew of $mysql1, $mysql2, etc., in a script, or, even worse, something ugly like $theInput or $theResult.

 

2. Single letter table aliases are common to the point of convention. Since aliases are defined within queries with the table names referenced, they don't need to have longer, more meaningful names.

 

3. There was no reason to call out Barand here. He wasn't involved until you mentioned him by name. Furthermore, your criticism was tangential to tactual issue at hand. If you have a problem with him, settle it in PMs. If you don't think that will solve it, PM a mod or admin.

 

---

 

To MaisieWebster: I don't generally answer homework questions because I feel that if you do your job as a student you should be able to successfully complete an assignment. In my experience, it's rare to find an instructor who is so deficient that they can't prepare their students for their own coursework. However, since we're close to the holidays, I'll be generous.

 

1. Create an HTML form that has a text input with the name "artistName". Have that form's method set to "post" and action set to your PHP script.

 

2. In your PHP script do the following:

 

<?php
$a = $_POST['artistName'];

echo "You entered: $a for the artist's name.";
?>

 

Since the assignment is incredibly easy, I've omitted any real life error checking or security precautions.

 

That should do it, provided there isn't anything you neglected to mention.

Link to comment
Share on other sites

I would have thought best place for your piece of puerile trolling was in response to one of my "nonsensical" posts, not here. At least my queries are relevant to the topic.

 

Aliases are useful and, at times, necessary. Perhaps you feel that the alias, if any, should be at least as long as the original table name. My use of them is totally legitimate, in stark contrast to your spelling. If you want to expose to the world your illiteracy in both English and SQL, feel free. But don't do at my expense.

LMAO, Trolling must have been redefined since I last heard it used. I took issue with your coding, you have taken that as a green light to attack me - that's cool, but I'll have to respond in kind.

I don't really class aliasing a select join using "as x" as legitimate in any circumstance. As for my spelling (the good old default comback from someone with pretty much nothing else), I'm dyslexic, I can't change that, It's a bit like your face - unfortunate but perminant. Your just fucking lazy. Worse than that, you are teaching people who are new to SQL and programming habbits bourn of that lazyness. Incidently there is more to litteracy than just spelling, but I guess your just too lazy to work that out.

 

1. One character variable names aren't inherently bad. Variable names should give an indication of the data the variable carries, but there's no length requirement. Is $i confusing in a for-loop? Is $a confusing in a small script where it's the ONLY variable in that script and is assigned to an artist's name? I'd much rather see that than a slew of $mysql1, $mysql2, etc., in a script, or, even worse, something ugly like $theInput or $theResult.

 

2. Single letter table aliases are common to the point of convention. Since aliases are defined within queries with the table names referenced, they don't need to have longer, more meaningful names.

 

3. There was no reason to call out Barand here. He wasn't involved until you mentioned him by name. Furthermore, your criticism was tangential to tactual issue at hand. If you have a problem with him, settle it in PMs. If you don't think that will solve it, PM a mod or admin.

...

 

1. Oxymoronic statement as it's almost impossible to maintain an indication of the data held in the variable by using a single letter, especialy when the code has to be maintaned by multiple programmers. As "i" has been used as a representative character for integer for at least 16 years now it's kind of a given what's in there, how many other's can you pick?

That there is only one variable in there is irrelivent, what's the harm in having the variable as $artist? Isn't that going to make a lot more sense to anyone else that ever tries to maintian the code in the future that doesn't have the original question to hand?

 

2. Because something is common it's ok? racism is common, ignorance is common, lazyness is common. None of those are things I would encourage people to be. I couldn't count the number of wasted hours trying to maintain code with single letter variables that I alone have had to spend.

 

3. I commented on Barands code, he commented on me. Both of which here in this thread yet I'm the one to be exclusively chastised? I "called Barand out" so to speak, as the thread I had read directly before this one was him doing exactly what I took issue with here to someone (who's topic was already solved), and then I come here and find the $a refference, all this on the back of spending a week trying to sift through someone elses code that's full of this crap.

 

So I tried to encourage someone new to coding to think about the variables that they use. Admitedly I used Barands code to do it, as he is the single main protagonist on here of such a lazy convention. My methods may indeed be questionable, the outcome may even be undesireable, but the intentions were not without merit. So warn me, suspend me, ban me if you think I diserve it. I will not change my opinions simply because it may hurt someones feelings to hear what I think.

Link to comment
Share on other sites

It's a bit like your face - unfortunate but perminant. Your just fucking lazy. Worse than that, you are teaching people who are new to SQL and programming habbits bourn of that lazyness. Incidently there is more to litteracy than just spelling, but I guess your just too lazy to work that out.

 

I think all of this can be solved in a more mature way, no? Barand uses table aliasing as does 99% of the other programmers because you just can't do a self-join without them nor can you for any complex queries like many-to-many. He writes kick ass queries with his eyes closed. Do you really think that by using insults you are changing the world? Make everyone somehow 'believe' in your method? All you are getting is a ban!

Edited by ignace
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.