Jump to content

Quick Fix!! Loops - driving me loopy


chestnuth

Recommended Posts

I have a textbox that contains the following values (A1 A2 A3 A5).

 

How can i loop through it to print each value to the screen on at a time? there maybe different amounts of numbers in the textbox each time. Would i use a for each?

 

Thanks

Link to comment
Share on other sites

Yes, seperated by a space!

 

Thanks for that!!

 

However, when i run this code it produces this:

 

Value: A1

Value: A2

Value: A3

Value: A5

Value:

 

and i am left with an empty value at the end, is this to do with my code?

 

<?php

session_start();

if (isset($_SESSION['username']) == false)

{

header("location:login.php");

exit();

}

$values = explode(' ', $_POST['thenames']);

foreach ($values as $value)

{

    echo "Value: $value<br>";

}

//header("location: changecontrol.php?var=change_control.ccid desc&view=1");

//exit();

?>

thanks!!

Link to comment
Share on other sites

Thanks guys, brill!!

 

i now want to use the id i got from the loop so 'A1' to start with. This will allow me to pick up the contents of the text box with the same name.

 

would i need to use something like this?

echo $_post['.$value.'];

 

or am i on the wrong lines completely?

 

Thanks

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.