$con=mysqli_connect("database.com.au","user","password","DATA_RECEIVER");
$srt='[[!$user_field]]';
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$result = mysqli_query($con,"SELECT * FROM data_events WHERE customer='$srt' ORDER BY date ASC");[[!$user_field]]
[[!Profile]] [[+mac]]
$profile = $modx->user->getOne('Profile');
if ($profile) {
$extended = $profile->get('extended');
$value = $extended['ExtendedFieldName'];
/* Do database query here */
} else {
/* user has no profile */
}
<?php
$profile = $modx->user->getOne('Profile');
if ($profile) {
$extended = $profile->get('extended');
$value = $extended['mac'];
$con=mysqli_connect("database.com.au","user","password","DATA_RECEIVER");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else {
/* user has no profile */
}
$result = mysqli_query($con,"SELECT * FROM data_events WHERE customer='$value' ORDER BY date ASC");
Thanks for the speedy reply Bob,
so have I got your reply correct?
<!--?php
$profile = $modx--->user->getOne('Profile');
$result = null;
if ($profile) {
$extended = $profile->get('extended');
$value = $extended['mac'];
$con=mysqli_connect("database.com.au","user","password","DATA_RECEIVER");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else {
$result = mysqli_query($con,"SELECT * FROM data_events WHERE customer='" . $value . "' ORDER BY date ASC");
}
} else {
/* user has no profile */
}
if ($result === null) {
/* Something went wrong */
} else {
/* process, return, or display $result */
}

$profile = $modx--->user->getOne('Profile');
$result = null;
if ($profile) {
$extended = $profile->get('extended');
$value = $extended['mac'];
$con=mysqli_connect("database.com.au","user","password","DATA_RECEIVER");
// Check connection
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
} else {
$result = mysqli_query($con,"SELECT * FROM data_events WHERE customer='" . $value . "' ORDER BY date ASC");
}
} else {
/* user has no profile */
}
if ($result === null) {
/* Something went wrong */
} else {
echo "<table>
<tbody>
<tr class='upper-td'>
<th>date</th>
<th>customer</th>
<th>id</th>
<th>q</th>
<th>c</th>
<th>z</th>
<th>p</th>
</tr>";
while($row = mysqli_fetch_array($result)) {
echo "<tr class='lower-td'>";
echo "<td class='lower-td'>" . $row['date'] . "</td>";
echo "<td class='lower-td'>" . $row['customer'] . "</td>";
echo "<td class='lower-td'>" . $row['id'] . "</td>";
echo "<td class='lower-td'>" . $row['q'] . "</td>";
echo "<td class='lower-td'>" . $row['c'] . "</td>";
echo "<td class='lower-td'>" . $row['z'] . "</td>";
echo "<td class='lower-td'>" . $row['p'] . "</td>";
echo "</tr>";
}
echo "</tbody>";
echo "</table>";
}
mysqli_close($con);
$row = mysquli_fetch_array($result); var_dump ($row);[/code
BTW, If I'm understanding what your doing, you're only going to get one row (the one for the current user) so the while loop is unnecessary.
$profile = $modx--->user->getOne('Profile');$profile =$modx->user->getOne(’Profile’);
echo "<br/>Value: " . $value; echo "<br><pre>" . print_r($extended, true) . "</pre><br/>";
SELECT * FROM `data_events` WHERE customer='001B110743DD' ORDER BY `date` DESC