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.
How2 Variable PHP inside while sql
Moderator: General Moderators
-
drigattieri
- Forum Newbie
- Posts: 3
- Joined: Sun Aug 17, 2008 4:13 am
Re: How2 Variable PHP inside while sql
Change Word_id to $Word_id.
-
drigattieri
- Forum Newbie
- Posts: 3
- Joined: Sun Aug 17, 2008 4:13 am
Re: How2 Variable PHP inside while sql
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!
+----------+--------------+
| 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!
-
drigattieri
- Forum Newbie
- Posts: 3
- Joined: Sun Aug 17, 2008 4:13 am
Re: How2 Variable PHP inside while sql
My problem is not how to Get Data From MySQL Database but
how to define variable from records.
thanks.
how to define variable from records.
thanks.
Re: How2 Variable PHP inside while sql
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.
1 - Start by copying that working example
2 - Modify to suit your needs
You have to do some of the work yourself.