I have a database that contains names, places, and several other fields. ID - University Name - Group Name - Website - Email Now I would like to have a way so that I can choose 'University Name' and have it display all the groups that are a part of that university. Or vice versa. Thats part 1. Part 2 coming soon. Thank you for all your help, I really appreciate it.
http://www.php-mysql-tutorial.com/ or http://www.tizag.com/mysqlTutorial/index.php You will have something like this <?php $dbhost = 'localhost'; //fill in your mysql host $dbuser = 'root'; //fill in your username $dbpass = 'password'; //fill in your password $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql'); $dbname = 'the_name_of_your_database'; //fill in the database name mysql_select_db($dbname); //connection to your db is made //now you need to select the table and select the info you need ?> Code (markup): Take a look at the tutorials..it's not that hard and start playing with it
Awesome I'm starting to understand a little bit. I'm going to want to specify a read only username correct? What permissions should just a read only username need? I'm using phpmyadmin for most of the work.
Just give the username that's going to be in public web pages the minimal permissions to function - mine have read and add access and that's it... (you can configure this from cpanel - which is easier than having to code a user table with specific permissions...) To answer one of your questions in order to select via University you'll need an SQL select statement like this: select * from table where university="'.$uni.'" where $uni is the variable that's populated by your pages drop-down list (or whatever input mechanism you're chosing... the select statement would then need to be wrapped in PHP: mysql_query=("select * from table where university="'.$uni.'" "); Check my syntax tho as I could be wrong!
Hey all I've been trying to format my PHP output on my script. So far I can do three things... Bold Italic Underline using b i u but thats it.. I have no clue how to use color or font or anything. Any ideas? It would be ideal to be able to have no border.. which I know how to do.. and have alternating font/text backing color for each row. Here's my script: <?php include('dbconnect.php'); ?><style type="text/css"> <!-- body { } --> </style> ... <?php // Get all the data from the "Groups" table $result = mysql_query("SELECT * FROM Groups") or die(mysql_error()); echo "<table border='1'>"; echo "<tr> <th><b>University</b></th> <th>Group</th> <th>State</th> <th>Zip Code</th> <th>Website</th> <th>Email</th> </tr>"; // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { // Print out the contents of each row into a table echo "<tr><td>"; echo $row['University_Name']; echo "</td><td>"; echo $row['Group_Name']; echo "</td><td>"; echo $row['State']; echo "</td><td>"; echo $row['Zipcode']; echo "</td><td>"; echo $row['Website']; echo "</td><td>"; echo $row['Email']; echo "</td></tr>"; } echo "</table>"; ?> Code (markup):