PHP - Select from database the same query

Posted by How to PHP on Stack Overflow See other posts from Stack Overflow or by How to PHP
Published on 2013-06-25T16:15:28Z Indexed on 2013/06/25 16:21 UTC
Read the original article Hit count: 254

Filed under:
|
|
|

I created a table that contains the name of the user and his job, and created PHP page that shows me all the users that works doctor, I entered doctor into a variable then I selected from the table where Jobs equal to $doctor, that is great, but I need it to get the same Jobs into a table in the page and the other same jobs into a table in the same page. this is my code that shows only the users works doctor in one table,

<html>
<h1>Doctors</h1>
</html>

<?php
mysql_connect('localhost','root','');
mysql_select_db('data');
$doctor='doctor';
$query= mysql_query("SELECT * FROM `users` WHERE `job` = '$doctor'")or die(mysql_error());
   while ($arr = mysql_fetch_array($query))
    $name= $arr['name'];
    echo $name;

}

?>

That shows me doctors when I put doctor in a variable I want to show all same Jobs in a table.

Is there is a way to do this? Thanks :)

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql