The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/printthread.php 16 require_once
Warning [2] Undefined property: MyLanguage::$archive_pages - Line: 2 - File: printthread.php(287) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/printthread.php(287) : eval()'d code 2 errorHandler->error
/printthread.php 287 eval
/printthread.php 117 printthread_multipage



UserSpice
View As User - Printable Version

+- UserSpice (https://userspice.com/forums)
+-- Forum: Support Center (https://userspice.com/forums/forumdisplay.php?fid=23)
+--- Forum: UserSpice 4.3 and Below (https://userspice.com/forums/forumdisplay.php?fid=26)
+--- Thread: View As User (/showthread.php?tid=344)

Pages: 1 2 3 4


View As User - mudmin - 11-23-2016

So I'm guessing you're doing something like
Code:
$uid = Input::get('id');

Now you have to run a query on that.

Code:
$theUserQ = $db->query("SELECT * FROM users WHERE id = ?",array($uid));
Code:
$theUser = $theUserQ->first();

Now you can echo out
Code:
$theUser->fname
to get the first name etc.


View As User - Brandin - 11-24-2016

And I'm having one more issue....currently, all of my pages that have direct scripts in them are using the following script for
Code:
$uid
capture:
<pre>
Code:
if(isset($_GET['uid']))
    {
        if(checkMenu(2,$user->data()->id))
        {
            $uid = $_GET['uid'];
        }
        else
        {
            $uid = $user->data()->id;
        }
    }
if (empty($_GET['uid']))
    {
    $uid = $user->data()->id;
    }
</pre>


However, a page has to perform a function the
Code:
$uid
is not passed along.

For example, on
Code:
functions.php
, there is two div's, one for
Code:
alerts
and one for
Code:
stats
. These divs are powered by the following JS:
<pre>
Code:
function autoRefresh_div() {
    $("#stats").load("/eldis/master/usersc/includes/stats.php");
    $("#alerts").load("/eldis/master/usersc/includes/alerts.php");
}
setInterval(autoRefresh_div, 1000); // every 5 seconds
autoRefresh_div(); // on load
</pre>


However, I run into the issue of the fact that when I am running these two URLs, I cannot push the
Code:
$uid
value. I was thinking that I could do something with the divs to enter the
Code:
$uid
which the
Code:
functions.php
figures out (based on the script above) but how do I pass this on to the JS? Once it's at the JS it'll be fine, but my issue is getting it to the JS.

Any help would be great!


View As User - mudmin - 11-24-2016

I'm terrible at JavaScript. I think you might have better luck pasting that function on stack overflow. I'll bet someone will answer it within a few hours.

Tell them all how great userspice is. Free advertising while you're at it Smile


View As User - Brandin - 11-24-2016

Mudmin,

Hopefully I will get someone good that won't yell at me about "situation specific" questions. Sometimes you get AMAZING people and sometimes you get really crappy people Sad I will post it there!

Thanks!


View As User - Brandin - 11-24-2016

This was much easier than I thought it would be.


FYI, to pass PHP variables to Javascript, just add something such as the following:
Code:
var uid = "<?php echo $uid ?>";

to the top of your JavaScript, and modify the links your JavaScript pushes to.


View As User - mudmin - 11-24-2016

I've seen that. I think as long as you state that you know the $uid, that takes userspice out of the equation...so not knowing why the variable isn't passing seems straightforward enough.


View As User - mudmin - 11-24-2016

Oh. Nice. I really need to step up my js game.


View As User - Brandin - 11-24-2016

That's okay, because I know crap about JS and CSS. I really only am good with PHP and mySQL. Give me a PDO and I'm fried lol. I'm still trying to learn PDO.


View As User - mudmin - 11-24-2016

Well, userspice makes the whole PDO thing a lot easier. I'm sure there are more advanced things you need to know, but you can do 99{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d} of what you ever need to do by knowing the basic

$db, query, insert, delete, update that US has.



View As User - mudmin - 11-24-2016

Well, userspice makes the whole PDO thing a lot easier. I'm sure there are more advanced things you need to know, but you can do 99{3bc1fe685386cc4c3ab89a3f76566d8931e181ad17f08aed9ad73b30bf28114d} of what you ever need to do by knowing the basic

$db, query, insert, delete, update that US has.