jonuk80
Forum Replies Created
-
That would be great. Thanks for your support again Peter
Best
Jon
Forum: Fixing WordPress
In reply to: SQL Table with clickable rowsI will investigate with wpDataTable, and that’s okay – I fully understand!!
The reason I haven’t done that (although maybe I’m making a blindingly stupid mistake here), is that I don’t want to have to make an individual page for every single project.
I was just hoping to have one page that could fetch the data for every new project where necessary. i.e. so there’s a master page, then data is grabbed via SQL to fill that page with information.
Please tell me I’ve missed something really obvious carike 🙂
- This reply was modified 6 years, 1 month ago by jonuk80.
Forum: Fixing WordPress
In reply to: SQL Table with clickable rowsThanks carike. 🙂 Okay – I won’t use JS for validation/santiation.
My best find so far is wpDataTables, which I’ve purchased. But it doesn’t quite do what I need. However I wouldn’t know where to begin custom coding it.
The only alternative is I try to write my own php, but that is also far beyond the realms of my little brain!
Thing is, I know it’s possible…I just don’t know how!
Hi Peter,
So every row is a unique URL. But that URL would have to be automatic (I think) so when you click it, it can take you to a page with more detailed information based on the particular row that was clicked. Does that make any sense?
Thanks 🙂
Jon
That’s great – thank you Peter! 🙂
Forum: Developing with WordPress
In reply to: Tables, Sessions & SQLFor anyone who’s interested, you don’t need the $wdbp prefix on custom tables in a query. Amending the code to below fixes it.
<?php
$current_user = wp_get_current_user();
$projectref = $wpdb->get_var(“SELECT pr_no FROM projects WHERE ID=$current_user->ID”);
echo “{$projectref}”;Forum: Developing with WordPress
In reply to: Tables, Sessions & SQLNo problem Steve – not trying to offend here, I’m just trying to learn.
Forum: Developing with WordPress
In reply to: Tables, Sessions & SQLThank you, that worked. I changed it to
<?php $current_user = wp_get_current_user(); $username = $wpdb->get_var( "SELECT display_name FROM $wpdb->users WHERE ID=$current_user->ID" ); echo "{$username}";Please can you shed some light on questions 2 & 3 above?
Forum: Developing with WordPress
In reply to: Tables, Sessions & SQLI think I’m getting closer to what I want. Using php snippets, I am able to insert the $wpdb->get_var command and pull single instances from the WP database, which works.
Maybe someone can help with the following questions.
1. On a page I have the following snippet
<?php $username = $wpdb->get_var( "SELECT display_name FROM $wpdb->users WHERE ID=2" ); echo "{$username}";This currently echos the display name from whoever user ID 2 is. How do I amend this statement so it shows the name of whoever’s logged in?
2. Going one step futher, I have created some custom tables i.e. wp_projects. For this one, I made this query.
<?php $projectref = $wpdb->get_var( "SELECT pr_no FROM $wpdb->projects WHERE user_id=1" ); echo "{$projectref}";However, it echos nothing, and comes up blank. Does the wpdb shortcode not work with custom tables?
3. If you can solve the above, can I go one step further with that code. You can see it’s just WHERE user_id=1, but I’d like it to display only the project number(s) relevant to the person logged in.
There is a FK in ‘projects’ user_id, which links to ‘wp_users’ ID.
Many thanks!
Forum: Developing with WordPress
In reply to: Tables, Sessions & SQLThanks Steve. That looks like quite a bit of coding know how.
I can’t believe it’s so hard to query single fields at a time and stick them on a page. Maybe I’m just being naive in thinking I can do it!
Thanks for the ETA peter 😉
I think I understand it, although I’m likely to need multiple project -> one login. Or maybe two logins -) multiple projects. Say a husband and wife wanted their own login but to access the same sets of data…
I will see what I can do with your fantastic tool for now however!! 🙂
Thanks!!
Hi Peter,
Not a stupid question at all, sorry I shouldn’t use acronyms! ETA = Estimated Time of Arrival. In other words, do you know when you might have this functionality implemented?
As for your other question, let me try and explain.
I want to use the ‘client portal’ as a tracking facility. In my work, for each client, I have to track a large number of things and would like to do it via a web interface.
Here’s a reduced example of the structure:
-
Tables
wp-users (my clients will go in here)
user-data (their addresses, telephone numbers etc)
projects (a list of all current projects, with status, project number etc)
project-constraints (a list of project constraints, like flooding, fire etc).-
Queries
This is where I get stuck! So on one page, I want to be able to, based on the user alone, query the database so it extracts information from ‘projects’ and ‘project-constraints’. In reality it’s about 7 tables. I figure if I can do it with 2, I can work out how to do the remaining 5.
So one page may say
Good morning $$user$$
Your current projects are (queried from ‘projects’)
$$project_name$$, $$project_status$$, $$project_link$$Most of the time it will be only one, but it could be more. They can then click on that project to a details page.
In that page it might say
$$project-name$$, $$project-ref$$
The current constraints are as follows
Flooding: $$project-constraints-flooding$$ (which will just be a yes, no or TBC)
Fire: $$project-constraints-fire$$
Notes: $$project-notes$$etc etc.
Does that make sense? 🙂
Kind regards
Jon
Forum: Developing with WordPress
In reply to: Tables, Sessions & SQLOkay looks like I need to do some WPDB learning :/ I wonder if there are any plugins that can help.
Naivety? I don’t really understand what I’m doing with WP and I’m trying to make a custom client portal. I’ve looked into plugins but none of them seem to do what I want. What are custom post types?
Forum: Developing with WordPress
In reply to: Tables, Sessions & SQLThanks, I’ll look into shortcode.
With my tables then, I’m guessing I will have to create a FK in projects, which links to the UserID (the default PK in WP)? I’m a bit stuck on how to do this. I know how to link the two in SQL, but I’m not sure how I link a query to the shortcode above!
Thanks again!
Forum: Developing with WordPress
In reply to: Tables, Sessions & SQLThanks Steve,
Can anyone shed any light on how I might achieve the above? Specifically question 3?
Cheers