Skip to content

Instantly share code, notes, and snippets.

@overwine
Created June 21, 2012 14:17
Show Gist options
  • Save overwine/2965988 to your computer and use it in GitHub Desktop.
Save overwine/2965988 to your computer and use it in GitHub Desktop.
Silly functions.
<?php
$deleteData = trim($_POST['bunch_id']);
$con = mysql_connect("nuts","penis","balls");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("chiquita-momcom", $con);
//mysql_query("DELETE FROM ballsack WHERE id='$deleteData'");
mysql_close($con);
?>
<h3>My Bunch</h3>
<script>
$('.delete-button').click(function(e) {
e.preventDefault();
alert("HURR!");
var $button, url, data;
$button = $(this);
url = '../../../../../wp-content/themes/chiquitamoms/members/single/delete_bunch.php';
data = { bunch_id: $this.data('id') };
$('#dialog-confirm').dialog({
resizable: false,
height:140,
modal: true,
buttons: {
'Yes': function() {
$.post(url, data, function(response) {
alert('Bunch deleted!');
});
$button.parent().parent().remove()
$(this).dialog( "close" );
},
'No': function() {
$(this).dialog( "close" );
}
}
});
});
</script>
<table border="0" cellspacing="0" cellpadding="0" class="my_bunch">
<tr>
<th>Relationship</th>
<th>Name</th>
<th>Nickname (optional)</th>
<th>Birthday</th>
<th></th> <!--Column added for delete button-->
</tr>
<?php
$options = "
<option value='Aunt'>Aunt</option>
<option value='Brother'>Brother</option>
<option value='Brother-In-Law'>Brother-In-Law</option>
<option value='Cousin'>Cousin</option>
<option value='Daughter'>Daughter</option>
<option value='Daughter-in-law'>Daughter-in-law</option>
<option value='Father'>Father</option>
<option value='Father-In-Law'>Father-In-Law</option>
<option value='Granddaughter'>Granddaughter</option>
<option value='Grandfather'>Grandfather</option>
<option value='Grandmother'>Grandmother</option>
<option value='Grandson'>Grandson</option>
<option value='Husband'>Husband</option>
<option value='Mother'>Mother</option>
<option value='Mother-in-law'>Mother-in-law</option>
<option value='Nephew'>Nephew</option>
<option value='Niece'>Niece</option>
<option value='Partner'>Partner</option>
<option value='Sister'>Sister</option>
<option value='Sister-In-Law'>Sister-In-Law</option>
<option value='Son'>Son</option>
<option value='Son-in-law'>Son-in-law</option>
<option value='Spouse'>Spouse</option>
<option value='Stepbrother'>Stepbrother</option>
<option value='Stepdaughter'>Stepdaughter</option>
<option value='Stepfather'>Stepfather</option>
<option value='Stepmother'>Stepmother</option>
<option value='Stepsister'>Stepsister</option>
<option value='Stepson'>Stepson</option>
<option value='Uncle'>Uncle</option>
<option value='Wife'>Wife</option>
";
for ($i=0; $i <=count($bunch); $i++) {
$x=$i;
$x++;
if ($bunch[$i]['birthday'] == '0000-00-00 00:00:00') { $bday = ''; } else { $bday = substr($bunch[$i]['birthday'], 0, -9); }
?>
<tr>
<td>
<select name="relationship[]" id="relationship_<?php echo $x; ?>">
<option value=''>-Select Relationship-</option>
<?php
$tmp = $bunch[$i]['relationship'];
if(!empty($tmp)) {
echo str_replace("value='". $tmp ."'","value='". $tmp ."' selected='selected'",$options);
} else {
echo $options;
}
?>
</select>
<?php
?>
</td>
<td>
<input name="bunch_name[]" type="text" class="bunch-name" value="<?php echo $bunch[$i]['name']; ?>" />
</td>
<td><input name="bunch_nickname[]" type="text" value="<?php echo $bunch[$i]['nickname']; ?>" /></td>
<td><input name="bunch_birthday[]" type="text" class='bday bunch-bday' id='datepicker_<?php echo $x; ?>' value="<?php echo (!empty($bday) ? date('m/d/Y',strtotime($bday)) : ''); ?>" /></td>
<td>
<?php
//die(var_dump($bunch)); great for seeing the whole array list
$b = $bunch[$i]['id'];
$n = $bunch[$i]['name'];
if(!empty($b)) {
?>
<div class="delete-button" data-id="<?php echo $bunch[$i]['id'] ?>">Delete</div>
<?
}
?>
</td>
</tr>
<? } ?>
<tr>
<td></td>
<td></td>
<td></td>
<td><a id="add_bunch_fields" class="add_button" href="">[Add Another]</a></td>
</tr>
</table>
<?php } ?>
<div class="pro_btns">
<?php /* ?><a href="<?php bp_loggedin_user_link();?>" class="btn_preview">PREVIEW YOUR PROFILE</a><?php */ ?>
<input type="submit" value="SAVE" name="saveprofile" class="input_submit">
<div id="dialog-confirm" class="confirm-hide" title="Delete Bunch Member?">
<p>Are you sure you want to delete this bunch member?</p>
</div>
</div>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment