V
V
Valery Pankov2015-11-13 01:34:42
PHP
Valery Pankov, 2015-11-13 01:34:42

How to pull out from the table all records in which the field "user"=$search?

It is necessary to pull out from the table all records in which the field "user"=$search and further to deduce in the table.
Here is an example, but it displays only one record - the last one, and all records are needed in which the field "user" = $search.

$result = mysql_query("SELECT * FROM table WHERE user='$search'",$db);
while ($myrow = mysql_fetch_array($result))
   {
     $th1 = '<th>'.$myrow['php'].'</th>';
     $th2 = '<th>'.$myrow['code'].'</th>';     
   }

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyacheslav Barsukov, 2015-11-13
@slavabars

$result = mysql_query("SELECT * FROM table WHERE user='$search'",$db);
while ($myrow = mysql_fetch_array($result))
   {

     $th1 .= '<th>'.$myrow['php'].'</th>';
     $th2 .= '<th>'.$myrow['code'].'</th>';

       
   }

O
OnYourLips, 2015-11-13
@OnYourLips

$result = mysql_query("SELECT * FROM table WHERE user='$search'",$db);

1. This feature is deprecated. It is deprecated in 5.6 and missing in 7.0.
2. You need to use prepared statements, you have SQL injection.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question