Answer the question
In order to leave comments, you need to log in
Retrieve a variable from the database?
Hello! How to pull out a variable from their db? I need to pull out the variable and substitute the value in $to
require 'cmsadmin/connect.php';
$sql_select = 'SELECT * FROM ordersait';
$result = mysql_query($sql_select);
$row = mysql_fetch_array($result);
do
{
printf("" .$row['email5'] . "");
}
while($row = mysql_fetch_array($result));
Answer the question
In order to leave comments, you need to log in
$sql_select = 'SELECT * FROM ordersait';
$result = mysql_query($sql_select);
while ($row = mysql_fetch_array($result)){
$to = $row['email5'];
}
printf("" .$row['email5'] . "");
replace with
but to be honest it’s not entirely clear what you need)
If more than 1 row is returned from the database, then only the LAST value will be written to the to variable
If you are sure that only 1 row will be returned from the database, then yes, my first option will work
But if there is a bullet more than 1 line then:
replace with
then AFTER the loop - to - is no longer a variable, but an array of variables
$sql_select = 'SELECT * FROM ordersait';
$result = mysql_query($sql_select);
$row = mysql_fetch_array($result);
foreach($row as $to){
echo $to['email5']
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question