Jump to content

Variables and Array help please


Vmi90

Recommended Posts

Ok, ive been reading php guide after guide, but i cant figure this out...

I want to make it so you type in something to be the variable.  Almost like a search engine would have it, but whatever you type in, thats the variable.  Also, if anyone could quickly explain how variables and arrays work in english please, i dont understand  ???
Link to comment
https://forums.phpfreaks.com/topic/28451-variables-and-array-help-please/
Share on other sites

If I understand, this is what you are asking:
If you use this page, it will say
Name and have a box to enter your name, then a Send button.

when you fill it out it will send this to the browser:
./send.php?name=John


<form method="GET" action="send.php">
Name:<input name="name" type="text" size="30" class="box">
<input type="submit" value="Send">
</form>

Next you have to do something with it:

send.php

<?php
$MyVariable=$_GET['name'];
echo $MyVariable;
?>

Now you took an input from one web page and made a $var out of it on another page.

Hope it's what you wanted...
A Variable contains an object

$MyVariable="Hello";
echo $MyVariable;

would render

Hello

In Simple terms, an Array is like a Variable but hold many items:

$MyVariable[0]="Apple";
$MyVariable[1]="Orange";
$MyVariable[2]="Pear";
$MyVariable[D]="Donut";

$MyVariable contains Apple, Orange, and Pear.

I Can call up one like this:

echo $MyVariable[1];

would render

Orange

whereas


echo $MyVariable[D];

would render

Donut

There are a lot of variations of arrays... It takes time to learn and understand them all.

[quote author=AV1611 link=topic=116281.msg473710#msg473710 date=1164483651]
If I understand, this is what you are asking:
If you use this page, it will say
Name and have a box to enter your name, then a Send button.

when you fill it out it will send this to the browser:
./send.php?name=John


<form method="GET" action="send.php">
Name:<input name="name" type="text" size="30" class="box">
<input type="submit" value="Send">
</form>

Next you have to do something with it:

send.php

<?php
$MyVariable=$_GET['name'];
echo $MyVariable;
?>

Now you took an input from one web page and made a $var out of it on another page.

Hope it's what you wanted...
[/quote]

Thats exactly what i wanted, but now that i have the box, whenever i send it, i dont want it to send me off that page.  I just want it so when you type it in, it becomes a variable please  :)

Archived

This topic is now archived and is closed to further replies.

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