Print

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Wackie
Forum Newbie
Posts: 14
Joined: Sat Mar 15, 2008 6:21 am

Print

Post by Wackie »

Hi.

I want to ask you, how to make a new printname for each print.

Code: Select all

print("&variablename1=$variable2");
So that my first print would be &variablename1,

second print &variablename2,

third print &variablename3, and so on.


Hope you can help me.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Print

Post by onion2k »

We'll need a bit more information about what you want to do. You either want a for..next loop, or an incrementing variable.

Also, you probably ought to use echo rather than print. Print is used if you need to check the return value ... as you're not checking it echo is more appropriate.
User avatar
Wackie
Forum Newbie
Posts: 14
Joined: Sat Mar 15, 2008 6:21 am

Re: Print

Post by Wackie »

Ok, what I want to do, is to get my data from mysql and load it via flash.
But for flash to load more data, I need the Echo variable to have different names.

Here is my script and I've changed the print to echo:

Code: Select all

<?php
$hostname = "localhost";
$username = "root";
$password = "********";
$usertable = "Table";
$dbName = "Database";
 
mysql_pconnect($hostname, $username, $password) OR DIE("DB connection unavailable");
@mysql_select_db("$dbName") or die( "Unable to select database"); 
$query = mysql_query("SELECT * FROM `$usertable`"); 
while ($row = @mysql_fetch_array($query)) 
{
$variable2=$row["variablename"]; 
 
echo("&variablename=$variable2");
}
?>
Frank Shi
Forum Newbie
Posts: 6
Joined: Thu Mar 13, 2008 4:03 am

Re: Print

Post by Frank Shi »

$variable2[]=$row["variablename"];
User avatar
Wackie
Forum Newbie
Posts: 14
Joined: Sat Mar 15, 2008 6:21 am

Re: Print

Post by Wackie »

I found another way of making my script, but thanks anyway Frank Shi. :D
Frank Shi
Forum Newbie
Posts: 6
Joined: Thu Mar 13, 2008 4:03 am

Re: Print

Post by Frank Shi »

:) :D
Post Reply