Go Back   Novahq.net Forum > Computers > Web design and Programming

Web design and Programming Discuss website creation and other programming topics.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 11-29-2005, 05:33 PM
Jeff is offline Jeff
Registered User

Join Date: Jun 2005
Posts: 1,602

Send a message via AIM to Jeff
PHP/MySQL

Hey everyone, i've started getting into minor php and mysql but i'm having some troubles.

http://www.exit-thirteen.com

I'm using mysql tables to hold all the info for my site... but i want to setup a form so that i can edit what has already been posted. How do i approach this?

My table rows are:

postID (not shown on webpage)
postTITLE <- the message's title
posterNAME <- now used for user input date
postTIME <- database time (not shown on webpage)
postTXT <- the message
__________________
Exit 13 - Web design and development.
My Blog - Read up on what i'm up to.
Reply With Quote
  #2  
Old 11-30-2005, 03:03 AM
Lakie is offline Lakie

Join Date: Mar 2002
Posts: 5,540

fetch all the mysql data for a given row and array it

$getnews=mysql_fetch_array(mysql_query("SELECT * FROM whereever WHERE id='1'");

that puts the returned data into an array, accessable by

$getnews[fieldname] (postTXT, postTIME etc)

You could just straight away use the array varibales to poulate a HTML form using the HTML value, and if its just you then you could do this, but it would be an idea to stripslashes, nl2br etc etc to do it properly...

I think anyway, p would be more help...
Reply With Quote
  #3  
Old 11-30-2005, 03:08 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

Alot of people have had very good success learning the basic functions of php by downloading my simple squad site.. it was one of the first scripts I ever wrote so it's pretty basic and easy to follow.

Mikes way above will work except there is one ")" missing at the end of the query, it should look like this:

$getnews=mysql_fetch_array(mysql_query("SELECT * FROM whereever WHERE id='1'"));
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #4  
Old 11-30-2005, 03:08 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

Probably help if i posted a link to my script:

http://www.phphq.net/scripts/SimpleSquadSite-v1.2.zip
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #5  
Old 11-30-2005, 03:26 AM
Lakie is offline Lakie

Join Date: Mar 2002
Posts: 5,540

Its actually your way (well, everything except the missing )), i learnt it of SSS, would have posted a link but didnt know you offered it for download
Reply With Quote
  #6  
Old 11-30-2005, 03:41 AM
Scott is offline Scott
Scott's Avatar
AKA. Panther

Join Date: Sep 2001
Location: Minneapolis, MN
Posts: 10,919

I wrote a basic script for you and anyone else that wants to learn.. It all starts from there, at least for me. Basic mysql select, display, delete, modify querys. It's not been debugged so there might be a few phrase errors..

I think you already know how to select data to be displayed but for anyone else that is wondering this is how it would be done following the script attached..

If your wondering what a function does look at http://www.php.net, enter the function name in the search box and read a little, it's extremly well documented, also read the user contributed notes as they help ALOT.
PHP Code:
<?
mysql_connect
("host","user","pass");
mysql_select_db("mysqldb");

$query=mysql_query("SELECT * FROM tbl_name ORDER BY postID ASC LIMIT 10");
while(
$result=mysql_fetch_array($query)) {
extract($resultEXTR_SKIP);

Echo
" ".$postTITLE." <br />";
Echo
" ".$posterNAME." <br />";
Echo
" ".$postTXT." <br />";
Echo
" ".date("m/d/y"$postTIME)." <br />";
Echo
" <br /> ";
Echo
" <br /> ";
}
?>
The above will show the latest 10 news posts..

Note, you will have to right click and view source to see the attached document in it's php form correctly..
Attached Files
File Type: txt php_basic_script.txt (2.8 KB, 8 views)
__________________

04' Dodge SRT-4, Mopar Stage 3, 406whp/436wtq
Reply With Quote
  #7  
Old 11-30-2005, 05:56 AM
Jeff is offline Jeff
Registered User

Join Date: Jun 2005
Posts: 1,602

Send a message via AIM to Jeff
Thanks, should help me out.
__________________
Exit 13 - Web design and development.
My Blog - Read up on what i'm up to.
Reply With Quote
  #8  
Old 11-30-2005, 12:18 PM
SilentTrigger is offline SilentTrigger
-1PARA-

Join Date: Sep 2002
Location: Sweden
Posts: 3,972

Theres also good info on php.net, thats where i lernt it hehe
__________________
-1PARA-AlexKall

My photography website



Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP and mySql atholon phphq.Net Forums 1 07-16-2008 01:25 PM
MySQL Problem or PHP? Webviper2006 Web design and Programming 3 12-26-2005 12:17 AM
php/mysql problem need help G.I.JOE*MFA* Web design and Programming 3 02-09-2004 05:20 PM
PHP, MySQL REGULATOR Web design and Programming 7 11-22-2003 11:53 AM
php and mysql XenoMorpH Web design and Programming 4 04-01-2003 06:14 AM


All times are GMT -5. The time now is 07:06 AM.




Powered by vBulletin®