PHP-MySQL help

Schoolies

Senior member
Oct 9, 1999
495
0
76
I am trying to build a website based on PHP and MYSQL. The functionality of the website is exactly like this website which uses ASP but I would like to use PHP:

Link

Basically all the website does is have links such as:
http://www.halloffamedance.com/regionals/regional?id=7

which after you click it, it goes to a template page and fills all the data in.

I'm looking to build a mysql database, make a template page which will be populated by data when the users clicks a URL.

I know this has been asked before and I don't want to waste anyone's time so if someone could post some quick code on this topic, I would appreciate it.

NOTE: I have looked through tons of php-mysql help web pages but none of them have helped much (and it doesn't help that I'm hard headed)

Thanks
 

AFB

Lifer
Jan 10, 2004
10,718
3
0
This isn't that generic, most of the code will have to be customized for what data you want to keep in the DB and how you store it.

But logically you would do this:

1)Query the DB and request it order the rows in a certain way
2)Then you would cycle through all the rows and fill in the data (Maybe a table)


You query might look like this

$query = "SELECT * FROM mydatabase WHERE id =". $_ GET['id'] . ""
 

Schoolies

Senior member
Oct 9, 1999
495
0
76
Thanks Amdfanboy

On the template page, would I be able to format that page the way I want it, with tables, font, etc. , and the data filled in automatically depending on what link the user clicks?
 

r6ashih

Senior member
May 29, 2003
667
0
0
you can format the page any way you want. you just have to build it around your sql query. So just make sure your query is working the way you want then do your webdesign.

Here is my weak php page that i'm working on:
http://gene2gene.com/test/index.php

if you enter 'a' into the search box , it searchs my database for everything in column 1 that starts with 'a' and shows it on screen

amdfanboy: do you know how to make that blue bar in my page more narrow or center the search box?
 

dighn

Lifer
Aug 12, 2001
22,820
4
81
Originally posted by: Schoolies
Right,

so I guess my real question is how do I format my results the way I want it...

well you can embed html code into your php script. for example, when you loop through the result set, you can output table rows.

example: if you have two fields

//query has been done before
echo '<table>':
while($record = mysql_fetch_row($recordset))
{
echo '<tr><td>'.$record[0].'</td><td>'.$record[1].'</td></tr>';
}
echo '</table>':

that will output each row in the record set as a row in html table

but that gets messy quickly. fortunately there are template engines like Smarty which can be used to seperate the HTML template and the PHP code and makes things much cleaner. it requires more setup and learning some syntax for the template engine which is not difficult but adds a layer of difficulty that can be bad for beginning