ricmcdonald Posted March 12, 2017 Share Posted March 12, 2017 Hi There I do not have enough php knowledge to achieve this simple task but I am guessing that someone here will be able to quickly help I have a successful query that returns members names and and a membership plan ID The data base name is wapja908_joom389 SELECT CONCAT( `first_name`," " , `last_name`) AS name,`plan_id`as plan FROM `josgw_osmembership_subscribers` where `plan_subscription_status` =1 ORDER BY `plan_id` I would like to be able to place this list into a web page, , the site is joomla based any help would be appreciated Quote Link to comment Share on other sites More sharing options...
shan2batman Posted March 12, 2017 Share Posted March 12, 2017 no need to complicate things, use wildcard in your query like "select * from table_name where condition='codition name' order by id" Quote Link to comment Share on other sites More sharing options...
shan2batman Posted March 12, 2017 Share Posted March 12, 2017 no need to complicate things, use wildcard in your query like "select * from table_name where condition='codition name' order by id" Quote Link to comment Share on other sites More sharing options...
shan2batman Posted March 12, 2017 Share Posted March 12, 2017 sorry typed two messages by mistake Quote Link to comment Share on other sites More sharing options...
ricmcdonald Posted March 12, 2017 Author Share Posted March 12, 2017 yes that is simple but that brings in all the fields in the table, I want to limit it to the name and plan id Ant then I need the PHP to place it onto a page Quote Link to comment Share on other sites More sharing options...
shan2batman Posted March 12, 2017 Share Posted March 12, 2017 ok then do this $query="select name, plan_id from table_name where condition='condition_name' order by id"; then execute the query with mysqli or pdo and create a loop and type the necessary html code like this <table> foreach($fetched_data as $content) { $result .=" <tr><td>".$content['name']."</td></tr> <tr><td>".$content['plan_id']."</td></tr> "; } echo $result; the above code will print it in table format, you can change it to any format and place it in your php page by either requiring or including the file or just run the loop in the same page. to place the $result in the desired place at any page you have to create a separate php file and loop in it and then call it in the desired place like require 'path to filename/filename.php'; or include 'path to filename/filename.php'; hope this helps forgive my english it isn't my mother tongue. Quote Link to comment Share on other sites More sharing options...
Solution benanamen Posted March 12, 2017 Solution Share Posted March 12, 2017 (edited) no need to complicate things, use wildcard in your query like "select * from table_name where condition='codition name' order by id" NO!, You always select the specific column names you want. DO NOT SELECT * Modify this to use the results of your query <!DOCTYPE html> <html> <head> <title></title> </head> <body> <form action="<?= $_SERVER['SCRIPT_NAME'] ?>" method="post"> <select name="sort_by"> <option value="">Select Option</option> <?php $array = array('id' => 'ID', 'name' => 'Name', 'amt' => 'Amount', 'status_filter' => 'Status'); foreach ($array as $key => $value) { $selected = isset($_POST['sort_by']) && $_POST['sort_by'] == $key ? 'selected' : ''; echo "<option value='$key' $selected>$value</option>\n"; } ?> </select> <input name="submit" type="submit" value="Submit"> </form> </body> </html> Edited March 12, 2017 by benanamen 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.