Page 1 of 1

How2 Variable PHP inside while sql

Posted: Sun Aug 17, 2008 4:21 am
by drigattieri
Hello all,
I need to define some VARIABLE php inside sql while cicle when I execute follow code:

$Vars = "SELECT word_id, `$language` FROM wordsite";
$VarsResult = mysql_query($Vars);
$VarsNumber = mysql_numrows($VarsResult);

$iVars = 0;


if ($VarsNumber < 1) {
print "no result";
}
else {
while ($VarsNumber > $iVars) {
$Word_id = mysql_result($VarsResult,$iVars,"word_id");
$Word = mysql_result($VarsResult,$iVars,"$language");

Word_id = "$Word"; // not work!!!
##############################
how to define so many variable how much the records are?
##############################

$iVars++;
}
}
print "$Word_id";
?>

Can you help me?
Thanks all.

Re: How2 Variable PHP inside while sql

Posted: Sun Aug 17, 2008 11:14 am
by ghurtado
Change Word_id to $Word_id.

Re: How2 Variable PHP inside while sql

Posted: Mon Aug 18, 2008 9:18 am
by drigattieri
no works. :|

+----------+--------------+
| word_id | word |
|----------+--------------|
| Var1 | hello world! |
|----------+--------------|
| Var2 | hello mars! |
|-------------------------|
|---....


I need to select two column(word_id and word) from a table
and configure result as php variables.

How to obtain following result??

$Var1 = "hello world!";

help me, please

$Word_id = "$Word"; ### NO WORKS!!! ###

thanks all!

Re: How2 Variable PHP inside while sql

Posted: Mon Aug 18, 2008 9:24 am
by ghurtado

Re: How2 Variable PHP inside while sql

Posted: Mon Aug 18, 2008 9:41 am
by drigattieri
My problem is not how to Get Data From MySQL Database but
how to define variable from records.


thanks.

Re: How2 Variable PHP inside while sql

Posted: Mon Aug 18, 2008 11:09 am
by ghurtado
Your problem is that you do not know how to do a basic mysql query and display the results in PHP. That is why I posted the link, because it contains a working example of what you want to do.

1 - Start by copying that working example
2 - Modify to suit your needs

You have to do some of the work yourself.