-1

I am having kind of stupid problem:P

<?php
echo $url; // In my php files $url contain multiple values
?>

This works fine
The different values of url get displays properly
For e.g
http://www.google.com
http://www.daniweb.com

That's perfect

Now when i tried to echo the variable in some html

<?php
$url = something; // In my php files $url contain multiple values
?>
<html>
<td><input type="text" size="50" value="<?php echo $url?>"/></td>
</html>

ONLY the first occurence of the variable url get displayed(i.e http://www.google.com)
HOW to make it display all values of $url in HTML
HTML need to be like this

<html>
<td><input type="text" size="50" value="<?php echo $url(first occurence)?>"/></td>
</html>
<html>
<td><input type="text" size="50" value="<?php echo $url(seconds occurence)?>"/></td>
</html>

Hope i will get this done soon

Thanks

3
Contributors
8
Replies
37
Views
5 Years
Discussion Span
Last Post by jasonsarino
0

It would be this, surely?:

<?php
$url = "something"; // In my php files $url contain multiple values
?>
<html>
<td><input type="text" size="50" value="<?php echo $url; ?>"/></td>
</html>

Ohhhhhhhh!! You're talking about arrays! Apologies!

So you'd have a list of values:

<?php
   $urls = array('www.google.com', 'www.yahoo.com', 'wwww.website.com');
   foreach($urls as $url) {
     echo $url;

   }

   // output
   //www.google.com www.yahoo.com wwww.website.com 
?>

So in theory, it would be something like this:

<?php
   $urls = array('www.google.com', 'www.yahoo.com', 'wwww.website.com');
   foreach($urls as $url) {
     echo '<td><input type="text" size="50" value="' .$url. '"/></td>';

   }
?>

Edited by phorce

0

You are partly right , the thing is that i want to echo the variable within html

Like this

     <html>
     <td><input type="text" size="50" value="<?php echo $url?>"/></td>
     </html>

But with all occurence of $url
$url is in a loop that's why it has multiple values
I think i expressed myself clear enough:P

0

It's unclear.

What your suggesting is that $url IS defined as a single variable, but has loads of values.. Almost to say:

$url = "www.google.com, www.yahoo.com";

Which, if this is the case then it's the wrong way to go around things.

I don't get what you mean "echo the variable within HTML" my example did that?

0

No $url is in a loop , it has one value @ a time
suppose i am uploading multiple files @ a time and storing the url in $url
Now the problem is that the only the first value of $url is printed in the html

?php
$url = something; // In my php files $url contain multiple values
?>
<html>
<td><input type="text" size="50" value="<?php echo $url?>"/></td>
</html>

What is what it to do is to print Code below multiple times and show the difference values of $url Not just the first one

<html>
<td><input type="text" size="50" value="<?php echo $url?>"/></td>
</html>
0

Right, show me (in your php file) how you're defining $url please. :)

i.e. The actual script!!

Edited by phorce

0

Fixed it myself
How i did

I put php tags within html + added a loop

1

Ok. Glad you sorted it out. Next time, be more specific in what it is you're actually trying to do!

0

<?php
ob_start();

$test = "Hello World";
echo $test;
?>

output:
Hello world

Edited by Ezzaral: Snipped blatant site promotion. Read the rules.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.