stlshawgo Posted November 13, 2010 Share Posted November 13, 2010 I'm not sure if my problem is with the PHP, MySQL, HTML, or all of the above, but I've used a tutorial from ScriptPlayground (http://scriptplayground.com/tutorials/php/Printing-a-MySQL-table-to-a-dynamic-HTML-table-with-PHP/) to print a table to HTML. My problem isn't that I couldn't get it to work, as you can see from my site, http://dollapal.com/offerlist.php I've used the code on my site, trying to display a list of offers, with links to each, but I actually have two questions: Is there a way to EXCLUDE columns of the table? I would rather not show the 'id' or 'points' columns, since they don't offer any worth to the user. I would also need to hopefully add a dollar sign before the 'pay' quantities if possible. I would also like use the 'title' field as a hyperlink to the URL listed in the 'URL' field, instead of simply printing the URL. Are there any simple ways to do this and not have it look terrible? I have included a copy of the script that I'm working with so far. Thank you in advance! [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 13, 2010 Share Posted November 13, 2010 The way the display_db_table function is written, it will display all the fields. You need to modify the function to accept the fields you want to display as a parameter, rather than having it use a wildcard * in the query string. Quote Link to comment Share on other sites More sharing options...
stlshawgo Posted November 13, 2010 Author Share Posted November 13, 2010 Thank you for that. That did solve one part of my question easy enough. I have corrected that problem to display the information that I would like. Do you know of any way to use the 'title' field as a hyperlink to the URL listed in the 'URL' field, instead of just displaying the URL? I also had the small dollar sign issue, but that is pretty insignificant. Thank you for the help so far! Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 13, 2010 Share Posted November 13, 2010 You'll need to figure out a way to use a conditional to determine which field is being echoed, and if it's the table's id field, format it with the html <a href tags, using the id as a GET var in the URL string so you can them process it with another script. Otherwise if it's the field containing the price, prepend a $ to the number. If you need help with either of those, just say so. Quote Link to comment Share on other sites More sharing options...
stlshawgo Posted November 13, 2010 Author Share Posted November 13, 2010 I'm not sure if I am understanding the first part of that response. I think I can figure out the second portion of your advice though. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 14, 2010 Share Posted November 14, 2010 Well, I'm kind of assuming that the table has an index. If it's the first field retrieved in each record, you'd need to determine that and format the output to echo it as a link, with the value of the index field in the url. If you're script to retrieve the specific information is called get_more.php, the link should end up something like if($column_num == 0 ) { echo "<a href=\"get_more.php?id=$row[0]\">See details</a> } else { // just echo it as normally done in the function } Hope that makes sense to you . . . 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.