Jump to content

Recommended Posts

How do I make the $sub_attributes_points display as blank or nothing if the calculation returns a value of "0"? Here is the code I have:

 

$get_sub_attribute_names = "select * from sub_attributes where id = '$sub_attributes_attribute_id'";
$get_sub_attribute_names_res = mysql_query($get_sub_attribute_names, $conn) or die(mysql_error());

while ($sub_attribute_names_info = mysql_fetch_array($get_sub_attribute_names_res)) {
$sub_attribute_names_id = $sub_attribute_names_info['id'];
$sub_attribute_names_attribute = $sub_attribute_names_info['sub_attribute'];
$sub_attribute_names_points = $sub_attribute_names_info['points'];
$sub_attributes_points = ($sub_attribute_names_points * $sub_attributes_level_id);

$display_block .= "
<tr>
<td class=indent>$sub_attribute_names_attribute</td>
<td class=align_levels>$sub_attributes_level_id</td>
<td class=align_levels>$sub_attributes_points</td>
</tr>";

}
}

I received this error when I changed that:

 

Parse error: parse error in C:\wamp\www\showprofile_scouts.php on line 370

 

Isn't it a problem using the <?php ?> tags within this code because it is already in php tags? How else can I do it? I had to do the same thing before, but I used an if statement, but I'm not sure how I'd do it here. Here is one I used before:

 

if($health == 0 || $health == '0' || $health == null){$GLOBALS['health'] = "";}

 

But since this one isn't from a value in the table, I don't know how i'd write it. Can anyone help?

Well, I did this and it worked:

 

$get_sub_attributes = "select * from scout_sub_attributes where identity = '$identity'";
$get_sub_attributes_res = mysql_query($get_sub_attributes, $conn) or die(mysql_error());

while ($sub_attributes_info = mysql_fetch_array($get_sub_attributes_res)) {
$sub_attributes_id = $sub_attributes_info['id'];
$sub_attributes_identity = $sub_attributes_info['identity'];
$sub_attributes_attribute_id = $sub_attributes_info['sub_attribute_id'];
$sub_attributes_level_id = $sub_attributes_info['level_id'];
$sub_attributes_notes = $sub_attributes_info['notes'];

$get_sub_attribute_names = "select * from sub_attributes where id = '$sub_attributes_attribute_id'";
$get_sub_attribute_names_res = mysql_query($get_sub_attribute_names, $conn) or die(mysql_error());

while ($sub_attribute_names_info = mysql_fetch_array($get_sub_attribute_names_res)) {
$sub_attribute_names_id = $sub_attribute_names_info['id'];
$sub_attribute_names_attribute = $sub_attribute_names_info['sub_attribute'];
$sub_attribute_names_points = $sub_attribute_names_info['points'];
$sub_attributes_points = ($sub_attribute_names_points * $sub_attributes_level_id);

$display_block .= "
<tr>
<td class=indent>$sub_attribute_names_attribute</td>";

if ($sub_attributes_level_id == null) {
$display_block .= "$sub_attributes_level_id";
} else {
$display_block .= "
<td class=align_levels>$sub_attributes_level_id</td>
<td class=align_levels>$sub_attributes_points</td>
</tr>";
}

 

I just added that if statement and it fixed the problem. Thanks for all the help!

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.