K
K
Kirill2016-01-28 11:19:36
PHP
Kirill, 2016-01-28 11:19:36

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));

thanks a lot

Answer the question

In order to leave comments, you need to log in

3 answer(s)
R
Ruslan, 2016-01-28
@Gavr23

$sql_select = 'SELECT * FROM ordersait';
$result = mysql_query($sql_select);
while ($row = mysql_fetch_array($result)){
      $to = $row['email5'];
}

R
Rodion Yurchenko, 2016-01-28
@aassdds

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

A
Alexander Pavlenko, 2016-01-28
@RichyNix

$sql_select = 'SELECT * FROM ordersait';
$result = mysql_query($sql_select);
$row = mysql_fetch_array($result);

foreach($row as $to){
 echo $to['email5']
}

I think the essence is clear, it will not be difficult to understand further

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question