Hello all

I am creating a page that dynamically updates as tables are added and removed from the database.

Like so:

#connect to mysql
$conn = @mysql_connect("localhost", "root", "*****")  
	                or die("Err:Conn");

#select db
$rs = @mysql_select_db("ecf_training", $conn)  
		or die("Err:Db");
			
$query="SELECT * FROM class";
$result=mysql_query($query);
$num=mysql_numrows($result);
	
$i=0;
	
if($num != 0){
     echo("<table class = 'courses' border = '1' BORDERCOLOR = 'black' cellpadding='0' cellspacing='0'> 
		<tr class = 'black'>
		<td>Date</td>
		<td>Course</td>
		<td>Time</td>
		</tr></font>");

	while ($i < $num) {
	
	$date=mysql_result($result,$i,"date");
	$type=mysql_result($result,$i,"type");
	$time=mysql_result($result,$i,"time");
	
	echo("
	<tr>
	<td>$date</td>
	<td>$type</td>
	<td>$time</td></tr>
	");
	$i++;
	}

And that works beautifully.

But I would like to add another column in the table that will echo the number of registered users in each class.

I know the code to get that done; however, I don't know how to access each class indivually.

Any ideas?

Thanks in advance :)

lg

what table holds the relationship between class and users?

Sorry, I forgot to include that.

When the table is created, two queries are executed.

$result="INSERT INTO ecf_training.class(table_name, date, type, time)
	VALUES(\"$class\", \"$date\", \"$type\", \"$time\")";

$result2="CREATE TABLE ecf_training.`$class` (`FirstName` TEXT NOT NULL, `LastName` TEXT NOT NULL, `address` TEXT NOT NULL, `city` TEXT NOT NULL, `state` TEXT NOT NULL, `zip` TEXT NOT NULL,`phone` TEXT NOT NULL, `email` TEXT NOT NULL,`role` TEXT NOT NULL) 					     ENGINE = MyISAM";

#execute query
	$rs = mysql_query($result, $conn)
		or die ("Err:Query1");
	$rs2 = mysql_query($result2, $conn)

So it inserts the class information (date, time, etc) in the class table, while also creating a new table for the user's information.

And I'm looking to echo the current number of registered user's for each individual class.

Hope this helps,

lg

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.