webmaster1 Posted December 7, 2008 Share Posted December 7, 2008 Again remember to change 'tablename' to your actual table name for: $query="SELECT * FROM tablename ORDER BY date DESC"; Secondly you'll need to add a basic url link at the end of form.php to allow the user to continue to view their own submission and those of others. Finally I noticed a little glitch with form.php: Find these lines: if ($username && $amount) { and replace them with: if ($username && $amount &&amountnumericcheck) { And finally replace these lines: Amount:<input type="text" name="amount" id="amount" value="<?php if (isset($_POST['amount'])) echo $_POST['amount']; ?>"/> <?php if ($message_amount) echo ''.$message_amount.''; ?> with: Amount:<input type="text" name="amount" id="amount" value="<?php if (isset($_POST['amount'])) echo $_POST['amount']; ?>"/> <?php if ($message_amount) echo ''.$message_amount.''; ?> <?php if ($message_amountnumericcheck) echo ''.$message_amountnumericcheck.''; ?> This prevents the user from entering anything other than a number. Quote Link to comment Share on other sites More sharing options...
webmaster1 Posted December 7, 2008 Share Posted December 7, 2008 well that will work im sure but clean up the font face stuff with some easy css on it would be alot better code Definatley, the resulting form is ugly and css would defo streamline it more neatly. I'll leave the artistic liberty to his own discretion for now though Quote Link to comment Share on other sites More sharing options...
webmaster1 Posted December 7, 2008 Share Posted December 7, 2008 Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in C:\xampp\htdocs\test\output.php on line 21 Don't move onto editing form.php until you get the output.php fixed. It should just be the table name. Quote Link to comment Share on other sites More sharing options...
webmaster1 Posted December 7, 2008 Share Posted December 7, 2008 Apologies, typo: The first edit for form.php should read: if ($username && $amount && $amountnumericcheck) { Quote Link to comment Share on other sites More sharing options...
dropfaith Posted December 7, 2008 Share Posted December 7, 2008 assuming his code formats the text the way you want id use this just change tablename <html> <head> <title>Donations</title> </head> <body> <table border="1" cellspacing="2" cellpadding="2"> <tr> <th>URN</th> <th>User Name</th> <th>Amount</th> <th>IP Address</th> <th>Date</th> </tr> <?php // includes include("dbinfo.php"); // open database connection $connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!"); // select database mysql_select_db($db) or die ("Unable to select database!"); // generate and execute query $query = "SELECT * FROM TABLENAME ORDER BY date DESC"; $result = mysql_query($query) or die ("Error in query: $query. " . mysql_error()); // if records present if (mysql_num_rows($result) > 0) { // iterate through resultset // print article titles while($row = mysql_fetch_object($result)) { ?> <tr> <td><?php echo $row->$urn; ?></td> <td><?php echo $row->$username; ?></td> <td><?php echo $row->$amount; ?></td> <td><?php echo $row->$ipaddress; ?></td> <td><?php echo $row->$date; ?></td> </tr> <?php } } // if no records present // display message else { ?> <?php } // close database connection mysql_close($connection); ?> </table> </body> </html> Quote Link to comment Share on other sites More sharing options...
webmaster1 Posted December 7, 2008 Share Posted December 7, 2008 assuming his code formats the text the way you want id use this just change tablename Yep, that looks a lot more conventional and standardized. What does -> do? I've seen it being used a few times. Looks like Birdie got it working: http://birdmansplace.myftp.org/test/output.php The date in your table only shows the date. Make sure your date column was set as datetime and not just date. Thats why the output order isn't ordered as it should be. Quote Link to comment Share on other sites More sharing options...
dropfaith Posted December 7, 2008 Share Posted December 7, 2008 to be completly honest im not to clear on it but ive been using it for ages and it kinda just stuck with me to keep using that style of echo im pretty sure its part of the $row being echoed and in my head its easier to read and understand Quote Link to comment Share on other sites More sharing options...
Birdmansplace Posted December 7, 2008 Author Share Posted December 7, 2008 drop: i did the table name change and i get this Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\test\output1.php on line 21 also i would like the date to sort by news date on top oldest on bottum. i think that what i read, well understood form your code drop. Also your code drop is at http://birdmansplace.myftp.org/test/output1.php Quote Link to comment Share on other sites More sharing options...
dropfaith Posted December 7, 2008 Share Posted December 7, 2008 my bad change your dbinfo.php file to this I didnt look at the file and used slightly different names for the fields <? // database configuration $host = "localhost"; //hostname $user = "USERNAME"; //username $pass = "PASSWORD"; password $db = "database name"; //database ?> Quote Link to comment Share on other sites More sharing options...
Birdmansplace Posted December 7, 2008 Author Share Posted December 7, 2008 mysql connection info is: dbinfo.php Quote Link to comment Share on other sites More sharing options...
webmaster1 Posted December 7, 2008 Share Posted December 7, 2008 I'm always pedantic when it comes to databases. Just create your new table from scratch using the first bit of SQL code I gave you rather than changing the name of the current table. The only thing that needs changing is the destined database and the desired table name. I think your date column is set as date rather than datetime. It needs the time as well to order correctly. Check mine here: http://www.joycepromotions.com/output.php Quote Link to comment Share on other sites More sharing options...
dropfaith Posted December 7, 2008 Share Posted December 7, 2008 it should sort by date newest to oldest with my code already order by date desc would do that Quote Link to comment Share on other sites More sharing options...
webmaster1 Posted December 7, 2008 Share Posted December 7, 2008 If the time looks off in my output.php page its because we're four hours ahead in Ireland. Yours should show differently. Quote Link to comment Share on other sites More sharing options...
Birdmansplace Posted December 7, 2008 Author Share Posted December 7, 2008 Alright guys. Thanks alot. saved me hours and hours of personal head beatings. I will leave the test folder and this info here for others to see. And i will export the .sql file. check it out: form:http://birdmansplace.myftp.org/test/form.php output:http://birdmansplace.myftp.org/test/output.php Download: http://birdmansplace.myftp.org/test/form.zip Quote Link to comment Share on other sites More sharing options...
dropfaith Posted December 7, 2008 Share Posted December 7, 2008 np ive been thru the days of head beatings on lawrenceguide.org like hundreds of them i didnt know php at all before that project and ended up with a user driven site with all dynamic content and ratings scripts over like 2 months or so Quote Link to comment Share on other sites More sharing options...
webmaster1 Posted December 7, 2008 Share Posted December 7, 2008 Good man! Three final things: 1) Your link to output.php should not be at the end of your form. It should only show after submit where it says 'Thank you username' After this line in form.php: echo "Thank you $username !"; paste echo "<a href='www.yoursite.com'>somelink</a>"; Do not use double quotations in the <a> tag. 2) At a later stage try editing the code I suggested earlier. As it stands users are allowed to enter non-numeric values into your amount text box. 3) When your happy with everything don't forget to close this thread (mark as solved at bottom of page). Glad to help, later! Quote Link to comment Share on other sites More sharing options...
webmaster1 Posted December 7, 2008 Share Posted December 7, 2008 np ive been thru the days of head beatings on lawrenceguide.org like hundreds of them i didnt know php at all before that project and ended up with a user driven site with all dynamic content and ratings scripts over like 2 months or so Mmm, I'm going to try Allisons Supreme Chocolate Chip Cookies recipe. Quote Link to comment Share on other sites More sharing options...
dropfaith Posted December 7, 2008 Share Posted December 7, 2008 haha they are pretty damn good i havent had time to add more content i need to get a bunch up to demonstat it in launched mode but its a pain tp type out recipes shows stories and all that movie reviews blah i need more projects then this haha Quote Link to comment Share on other sites More sharing options...
Birdmansplace Posted December 7, 2008 Author Share Posted December 7, 2008 Alright guys. Thanks alot. saved me hours and hours of personal head beatings. I will leave the test folder and this info here for others to see. And i will export the .sql file. check it out: form:http://birdmansplace.myftp.org/test/form.php output:http://birdmansplace.myftp.org/test/output.php Download: http://birdmansplace.myftp.org/test/form.zip Everything is current. Injoy Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.