Lambneck Posted April 9, 2008 Share Posted April 9, 2008 Hello, I have a single form that collects a user's resume information. The form consists of four fields: the user's 'Name' and 'Email', as well as a 'Subject' and 'Message'. That information is then stored in a mysql database. What I am trying to do is make it so the 'Subject' information of each user is displayed permanently as an individual link on another page in ascending order by Date as they are posted. Then, the more users that fill out the form the more links the page will display. The displayed links, when clicked on, would take the viewer to another page that would display the complete form data (Name, Email, Subject, Message) that coincides with the Subject link chosen. My question is how can I separate or gather the 'Subjects' from the other collected form data(Name, Email, Subject, Message) and compile them as links to that corresponding form data? ??? A demonstration of what I am trying to accomplish can be found <a href="http://www.eslcafe.com/jobs/wanted/#PostMessage">here</a>. Any and all advice will be greatly appreciated. Thanks. Link to comment https://forums.phpfreaks.com/topic/100267-displaying-form-data/ Share on other sites More sharing options...
writer Posted April 9, 2008 Share Posted April 9, 2008 Once you store the data, you can manipulate it however you want using your $query string. Link to comment https://forums.phpfreaks.com/topic/100267-displaying-form-data/#findComment-512671 Share on other sites More sharing options...
Lambneck Posted April 9, 2008 Author Share Posted April 9, 2008 Thanks for the advice! However, I am kinda looking for more information than that because I am pretty new to php. How can I specify just the 'Subject' rather than everything in the table? I tried this code but its not working out for me: <?php $table = 'Info'; if (!mysql_connect($db_host, $db_user, $db_pwd)) die("Can't connect to database"); if (!mysql_select_db($database)) die("Can't select database"); $result = mysql_query("SELECT subject FROM {$table}"); if (!$result) { die("Query to show fields from table failed"); } while($row = mysql_fetch_row($result)) { $subject = $row[4]; echo "Subject : $subject <br>"; } mysql_free_result($result); ?> Link to comment https://forums.phpfreaks.com/topic/100267-displaying-form-data/#findComment-512771 Share on other sites More sharing options...
uniflare Posted April 9, 2008 Share Posted April 9, 2008 <?php $table = 'Info'; mysql_connect($db_host, $db_user, $db_pwd) or die("Can't connect to database: ".mysql_error()); mysql_select_db($database) or die("Can't select database"); $result = mysql_query("SELECT `subject` FROM `$table`") or die("Query to show fields from table failed: ".mysql_error()); while($row = mysql_fetch_array($result)) { echo "Subject : $row['subject'] <br />"; } mysql_free_result($result); ?> notice the changes i made: Used mysql_fetch_array instead. Changed the echo variable. Also: Changed the error handling statements for mysql functions to or die(). Added mysql_error() function to the error output (to see what mysql said). Cosmetically changed the mysql query, don't think you need braces for variables in strings. hope this helps, Link to comment https://forums.phpfreaks.com/topic/100267-displaying-form-data/#findComment-512810 Share on other sites More sharing options...
writer Posted April 9, 2008 Share Posted April 9, 2008 Nice work, uniflare. Link to comment https://forums.phpfreaks.com/topic/100267-displaying-form-data/#findComment-513131 Share on other sites More sharing options...
uniflare Posted April 9, 2008 Share Posted April 9, 2008 thanks Link to comment https://forums.phpfreaks.com/topic/100267-displaying-form-data/#findComment-513448 Share on other sites More sharing options...
Lambneck Posted April 10, 2008 Author Share Posted April 10, 2008 Thank uniflare! Link to comment https://forums.phpfreaks.com/topic/100267-displaying-form-data/#findComment-513468 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.