[solved]address 2 problems with syntax, full code provided
Posted: Tue Mar 09, 2004 2:59 am
ok heres the code in question first and foremost
do not worry about line 1 ($!sortby etc) as that is for a search function that i have
anyway basically i want to things to happen with this code and no matter how i try to write it it wont work:
1) create a DATE_FORMAT for more than one field
however this wont work and i kind find anything about 'double' formatting in the MySQL manual only single
also
i have a value in my last_login of "NULL" (completely empty in MySQL) so when i print this it comes out with a blank value and knocks my CSS cells out of place because of the lack of or <spacer> so i tried this
i dont think this is correct but atm my heads 2 screwed up over constant coding
i also tried
and this didnt work
any help would be great
Mal
Code: Select all
if ((!$sortby) || (!$orderby) || (!$limitto))
{
//the query defined
$query = "SELECT *, DATE_FORMAT(last_login, '%H:%i - %d/%m/%y ') AS last_login FROM members ORDER BY access_level ASC" or die(mysql_error());
// query the database
$result = mysql_query($query);
// display all the results for everyone
$row1 = mysql_fetch_array($result, MYSQL_ASSOC);
$nomembers = mysql_num_rows($result);
// if statement to change the value of $row1[last_login] in case the user is yet
// to login to the site
/////////////////add here////////////////////////////
print "
<form action="profile-viewer.php" method="post" name="$row1[username]_form" id="$row1[username]_id">
<tr>
<td class="usernamerow">$row1[username]
<input name="username2pass" type="hidden" id="username2pass" value="$row1[username]">
</td>
<td class="emailrow">$row1[email]</td>
<td class="registeredrow">$row1[register_date]</td>
<td class="activityrow">$row1[last_login]</td>
<td class="usergrouprow">$row1[access_level]</td>
<td class="buttonrow"><input class="adminbutton" name="$row1[username]button" type="submit" id="$row[username]button" value="More.."></td>
</tr>
</form>";
while ($row2 = mysql_fetch_assoc($result))
print "
<form action="profile-viewer.php" method="post" name="$row2[username]_form" id="$row2[username]_id">
<tr>
<td class="usernamerow">$row2[username]
<input name="username2pass" type="hidden" id="username2pass" value="$row2[username]">
</td>
<td class="emailrow">$row2[email]</td>
<td class="registeredrow">$row2[register_date]</td>
<td class="activityrow">$row2[last_login]</td>
<td class="usergrouprow">$row2[access_level]</td>
<td class="buttonrow"><input class="adminbutton" name="$row2[username]button" type="submit" id="$row2[username]button" value="More.."></td>
</tr>
</form>";
}anyway basically i want to things to happen with this code and no matter how i try to write it it wont work:
1) create a DATE_FORMAT for more than one field
i want it to be something like:me wrote:Code: Select all
$query = "SELECT *, DATE_FORMAT(last_login, '%H:%i - %d/%m/%y ') AS last_login FROM members ORDER BY access_level ASC" or die(mysql_error());
Code: Select all
$query = "SELECT *, DATE_FORMAT(last_login, register_date '%H:%i - %d/%m/%y ,'%d/%m/%y') AS last_login, register_date FROM members ORDER BY access_level ASC" or die(mysql_error());also
i have a value in my last_login of "NULL" (completely empty in MySQL) so when i print this it comes out with a blank value and knocks my CSS cells out of place because of the lack of or <spacer> so i tried this
Code: Select all
// if statement to change the value of $row1[last_login] in case the user is yet
// to login to the site
if ($row1[last_login] = "NULL")
{
$row1[last_login] = "Never";
}
else
{
}i also tried
Code: Select all
// if statement to change the value of $row1[last_login] in case the user is yet
// to login to the site
if (empty($row1[last_login]))
{
$row1[last_login] = "Never";
}
else
{
}any help would be great
Mal