Lurk
Active Member
- Joined
- Dec 4, 2017
- Messages
- 336
- Reaction score
- 48
Helo, I just added this to my server NPC - Marriage system 8.6+ [Fixed] (https://otland.net/threads/marriage-system-8-6-fixed.161590/) and I wanted to show on my website who the characters were married to and I managed to do it but the code is so ugly it makes me sad can anyone help? here's what I've done
here's how it looks on the website
PHP:
<?php
$is_married = false;
$player_id = (int)$user_id;
$db_query = "
SELECT `partner`
FROM `marriage_system`
WHERE `player_id`={$player_id}
";
$marriedto = mysql_select_single($db_query);
$marriedto = ($marriedto !== false) ? (int)$marriedto['partner'] : 0;
if ($marriedto != false){
$is_married = true;
$db_query = "
SELECT `name`
FROM `players`
WHERE `id`={$marriedto}
";
$nameofparter = mysql_select_single($db_query);
$nameofparter = (string)$nameofparter['name'];
}
$is_married2 = false;
$player_id = (int)$user_id;
$db_query = "
SELECT `player_id`
FROM `marriage_system`
WHERE `partner`={$player_id}
";
$partnerof = mysql_select_single($db_query);
$partnerof = ($partnerof !== false) ? (int)$partnerof['player_id'] : 0;
if ($partnerof != false){
$is_married2 = true;
$db_query = "
SELECT `name`
FROM `players`
WHERE `id`={$partnerof}
";
$nameofplayer = mysql_select_single($db_query);
$nameofplayer = (string)$nameofplayer['name'];
}
?>
<!-- is married? nameofplayer -->
<?php if ($is_married): ?>
<tr>
<td><b>Married to</b></td>
<td><a href="characterprofile.php?name=<?php echo $nameofparter; ?>"><?php echo $nameofparter; ?></a></td>
</tr>
<?php endif; ?>
<!-- is married? nameofplayer -->
<?php if ($is_married2): ?>
<tr>
<td><b>Married to</b></td>
<td><a href="characterprofile.php?name=<?php echo $nameofplayer; ?>"><?php echo $nameofplayer; ?></a></td>
</tr>
<?php endif; ?>
here's how it looks on the website