PDA

View Full Version : The Best Angle To Create This PHP/MYSQL Site...



iamapathy
May 2nd, 2003, 11:42 AM
Hi, im trying to figure out the best way to create this PHP/MYSQL website. It has news and events which will be stored in a MYSQL database.

To insert data I will create a insert form.

To update data I want the exisiting rows to be listed in a list menu, so that I can select it, and then have it bring up a page where it would load the current data from the database into an editable form. At which point when complete with the editing, it would update the database.

And to delete a database, the user will simply select the row and click the delete button to delete it.

And then on the actual page, the link will be 'http://my.domain/news.php?pageid=someVariable' where someVariable is the name of the page. How will I be able to tell the database to choose to bring in all the data that has to do with someVariable. I know it will have to look something like this, 'SELECT * FROM news WHERE pageid=$pageid' but having not done this before, I am unsure of how to do it efficently.

Can anyone give guidance on any of the issues I have? Also is it wise to do multiple queries in one php page?

Thanks,
Jordan.

comicGeek
May 3rd, 2003, 01:51 AM
That is exactly what you should do! It is ike doing a search. You first search your database the value of pageid.


SELECT * FROM news WHERE pageid = $pageid

You have to place that in a variable so you can use the information it returns to you:



$select = mysql_query('SELECT * FROM news WHERE pageid = $pageid');

$row = mysql_fetch_array($select);
echo '$row[pageid]';




It's been a long time since my last PHP scripting but I think this is the basic structure for your problem.


Cheers!

iamapathy
May 5th, 2003, 12:09 PM
Originally posted by comicGeek



$row = mysql_fetch_array($select);
echo '$row[pageid]';



Thanks, but isn't that code, simply pulling out the information and listing it? Is there a way to make certain mySQL cells appear in certain areas of the page, using the method you used? I mean I know there is a way, but I'm very new to this.

Thanks.

comicGeek
May 5th, 2003, 10:22 PM
I don't know about that but I think the theory is placing the variable "$row[pageid]" inside a useful html code to display it instead of using "echo".

Just explore this:


echo '<textarea name="test">'.$row[pageid].'</textarea>';


I hope you can get it to work. I myself am new to PHP and MySQL. If you want visit this link for tutorials:

www.robouk.com


Cheers!

iamapathy
May 6th, 2003, 12:52 PM
Originally posted by comicGeek
I don't know about that but I think the theory is placing the variable "$row[pageid]" inside a useful html code to display it instead of using "echo".

Just explore this:


echo '<textarea name="test">'.$row[pageid].'</textarea>';


I hope you can get it to work. I myself am new to PHP and MySQL. If you want visit this link for tutorials:

www.robouk.com


Cheers!

so what if instead of using the 'pageid' in $row[pageid] i used 'news', where news was the name of the cell, i wanted to retrieve?

iamapathy
May 6th, 2003, 12:54 PM
by the way, nice site, i love the look... minus all the smiley faces :P

comicGeek
May 7th, 2003, 01:20 AM
yeah you can can that depends on what the information on the database you wanted to retrieve.

iamapathy
May 7th, 2003, 10:09 AM
Cool, any insight on how to create listbox entry chooser for loading the data into editable text areas and for deleting?

comicGeek
May 7th, 2003, 10:02 PM
I really haven't explored on that area before. I think the theory is the same. :-\

iamapathy
May 10th, 2003, 10:58 AM
Originally posted by comicGeek
I really haven't explored on that area before. I think the theory is the same. :-\

it's ok, i managed to figure it out.... thanks (-:

iamapathy
May 12th, 2003, 11:06 AM
The next issue i have, is trying to display the most recent news articles...

I want to be able to display three news articles, which are not unposted. The question is how can this be done?

Initially this is what i was thinking...


SELECT * FROM news WHERE id > max(id)-3 & unposted = null

'max(id)-3 & unposted = null' is just something that i wrote which is not mysql, but hopefully will help yu see what i am doing.

Thanks.

iamapathy
May 21st, 2003, 10:16 AM
actually i figured that out too, with this mysql query


SELECT * FROM news WHERE unposted IS NULL ORDER BY id DESC LIMIT 3

although i do have another problem which is,


creating a calender database, which display events which are annual as well as events that only happen once.