PHP - X Minutes Ago Or X Hours Ago From A Mysql Entry
so i have a mysql column with a datetime and i was wondering how i could make it echo the time in "X minutes ago" or "X hours ago" and also, when its more then 24 hours old, delete the entire entry
Similar TutorialsOther than if statement, is there a way to change a duration give in seconds (e.g. 5746 seconds) to the standard format of x hours and y minutes and z seconds? This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=352669.0 Code: [Select] function time_ago($timestamp) { //$months = array("Jan" => 31, "Feb" => 28, "Mar" => 31, "Apr" => 30, "May" => 31, "Jun" => 30, "Jul" => 31, "Aug" => 31, "Sept" => 30, "Oct" => 31, "Nov" => 30, "Dec" => 31); $curr_time = time(); $time_ago = $curr_time - $timestamp; if($time_ago < 60) // seconds { $ext = $time_ago . " seconds ago.."; } else { if($time_ago >= 60) // minutes { $time = floor($time_ago / 60); $seconds_remainder = $time_ago % 60; $ext = $time . " minutes " . $seconds_remainder . " seconds ago.."; if($time >= 60) // hours { $hours = floor($time / 60); $minutes = $time % 60; $ext = $hours . " hours " . $minutes . " minutes ago.."; if($hours >= 24) // days { $days = floor($hours / 24); $day_hours = $hours % 24; $ext = $days . " days " . $day_hours . " hours ago .."; } } } } return $ext; } Is there a cleaner approach to this? Code: [Select] function time_ago($timestamp) { //$months = array("Jan" => 31, "Feb" => 28, "Mar" => 31, "Apr" => 30, "May" => 31, "Jun" => 30, "Jul" => 31, "Aug" => 31, "Sept" => 30, "Oct" => 31, "Nov" => 30, "Dec" => 31); $curr_time = time(); $time_ago = $curr_time - $timestamp; if($time_ago < 60) // seconds { $ext = $time_ago . " seconds ago.."; } else { if($time_ago >= 60) // minutes { $time = floor($time_ago / 60); $seconds_remainder = $time_ago % 60; $ext = $time . " minutes " . $seconds_remainder . " seconds ago.."; if($time >= 60) // hours { $hours = floor($time / 60); $minutes = $time % 60; $ext = $hours . " hours " . $minutes . " minutes ago.."; if($hours >= 24) // days { $days = floor($hours / 24); $day_hours = $hours % 24; $ext = $days . " days " . $day_hours . " hours ago .."; } } } } return $ext; } It seems to work fine (was going to tackle Months but haven't done it yet), but anyway is there a better way to do this? I'm guessing there is as I wrote this up rather fast and I'm not that great with date math. Any suggestions are appreciated (besides maybe using ternaries which I'm working on atm).
Hi, echo '<div style="float:right;width:60%;color:#666666">'. TeamSpeak3_Helper_Convert::version($ts3->virtualserver_uptime) .'</div>'; Edited June 24, 2020 by Lux05 Alright, wasn't quite sure how to summarize this in the title, but I want to: Check if a user status is "active" or not based on the UserName input. I have a table witch holds: Code: [Select] VarChar Username Var CharPassWord int Active Ted TedsPW 1 something like the above(assuming it formatted correctly. In my php script I will want to input a variable for Username to check for: inputUN in this example would be "Ted". $UserNameToCheck = $_GET['inputUN']; Then I want to check for that UserName in the database, if it exists, I want pull the value for the "Active" field for just that UserName and echo it. Thanks for any help. I am using php to upload a file to my server, and at the same time inserting the files name and url into my mysql database.
$sql = "UPDATE uploads SET name = '$name', url='$target_path'"; $statement = $dbh->prepare($sql); $statement->execute();This is working, however, when I upload a new file, rather than making a new entry in my database, it just overwrites the first one. I'm quite new at mysql so was wondering how I would make it add new entrys instead of overwriting the current one? basically could somebody help me with information on having a php script that deletes mysql rows which are older than 3 hours old. I know MYSQL table will need a date/time column but how can I only target ones which are 3 hours old+. Thanks I tried adding a group field to my user table so I can show different content to different users but when I do the check and then if/else the required info it doesn't seem to do it. I think I've got a mistake in my query: <?php include ('header.php'); ?> </center> <?php $username = mysql_real_escape_string($_POST['username']); $checkadmin = mysql_query("SELECT Group FROM users WHERE Username = '".$username."'"); if('$checkadmin' == GroupA) { ?> Welcome Admin! <?php } else { ?> You are not authorised. <?php } include ('footer.php') ?> Whats wrong with it? Cheers. I wrote a site for work that holds employee schedule. By demand of my manager she would like an edit function with out having to re-enter the hole thing. She is very BLOND!! the layout has to stay the same other wise she will never figure it out. i need to be query the db pull the info, edit it and send it back or get it info and then delete then enter new. this is the code i already use to query the info from the db: Code: [Select] <? ini_set("display_errors", "1"); error_reporting(E_ALL); include("dbinfo.php"); mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM schedule ORDER BY date DESC LIMIT 2"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $date=mysql_result($result,$i,'date'); $urn=mysql_result($result,$i,'urn'); $date0=mysql_result($result,$i,'date0'); $date1=mysql_result($result,$i,'date1'); $date2=mysql_result($result,$i,'date2'); $date3=mysql_result($result,$i,'date3'); $date4=mysql_result($result,$i,'date4'); $date5=mysql_result($result,$i,'date5'); $date6=mysql_result($result,$i,'date6'); $date7=mysql_result($result,$i,'date7'); $day=mysql_result($result,$i,"day"); $day1=mysql_result($result,$i,"day1"); $day2=mysql_result($result,$i,"day2"); $day3=mysql_result($result,$i,"day3"); $day4=mysql_result($result,$i,"day4"); $day5=mysql_result($result,$i,"day5"); $day6=mysql_result($result,$i,"day6"); $day7=mysql_result($result,$i,"day7"); $row1=mysql_result($result,$i,"row1"); $row2=mysql_result($result,$i,"row2"); $row3=mysql_result($result,$i,"row3"); $row4=mysql_result($result,$i,"row4"); $row5=mysql_result($result,$i,"row5"); $row6=mysql_result($result,$i,"row6"); $row7=mysql_result($result,$i,"row7"); $row8=mysql_result($result,$i,"row8"); $row9=mysql_result($result,$i,"row9"); $row10=mysql_result($result,$i,"row10"); $row11=mysql_result($result,$i,"row11"); $row12=mysql_result($result,$i,"row12"); $row13=mysql_result($result,$i,"row13"); $row14=mysql_result($result,$i,"row14"); $row15=mysql_result($result,$i,"row15"); $row16=mysql_result($result,$i,"row16"); $row17=mysql_result($result,$i,"row17"); $row18=mysql_result($result,$i,"row18"); $row19=mysql_result($result,$i,"row19"); $row20=mysql_result($result,$i,"row20"); $row21=mysql_result($result,$i,"row21"); $row22=mysql_result($result,$i,"row22"); $row23=mysql_result($result,$i,"row23"); $row24=mysql_result($result,$i,"row24"); $row25=mysql_result($result,$i,"row25"); $row26=mysql_result($result,$i,"row26"); $row27=mysql_result($result,$i,"row27"); $row28=mysql_result($result,$i,"row28"); $row29=mysql_result($result,$i,"row29"); $row30=mysql_result($result,$i,"row30"); $row31=mysql_result($result,$i,"row31"); $row32=mysql_result($result,$i,"row32"); $row33=mysql_result($result,$i,"row33"); $row34=mysql_result($result,$i,"row34"); $row35=mysql_result($result,$i,"row35"); $row36=mysql_result($result,$i,"row36"); $row37=mysql_result($result,$i,"row37"); $row38=mysql_result($result,$i,"row38"); $row39=mysql_result($result,$i,"row39"); $row40=mysql_result($result,$i,"row40"); $row41=mysql_result($result,$i,"row41"); $row42=mysql_result($result,$i,"row42"); $row43=mysql_result($result,$i,"row43"); $row44=mysql_result($result,$i,"row44"); $row45=mysql_result($result,$i,"row45"); $row46=mysql_result($result,$i,"row46"); $row47=mysql_result($result,$i,"row47"); $row48=mysql_result($result,$i,"row48"); $row50=mysql_result($result,$i,"row50"); $row51=mysql_result($result,$i,"row51"); $row52=mysql_result($result,$i,"row52"); $row53=mysql_result($result,$i,"row53"); $row54=mysql_result($result,$i,"row54"); $row55=mysql_result($result,$i,"row55"); $row56=mysql_result($result,$i,"row56"); $row57=mysql_result($result,$i,"row57"); $row58=mysql_result($result,$i,"row58"); $row59=mysql_result($result,$i,"row59"); $row60=mysql_result($result,$i,"row60"); $row61=mysql_result($result,$i,"row61"); $row62=mysql_result($result,$i,"row62"); $row63=mysql_result($result,$i,"row63"); $row64=mysql_result($result,$i,"row64"); $row65=mysql_result($result,$i,"row65"); $drive1=mysql_result($result,$i,"drive1"); $drive2=mysql_result($result,$i,"drive2"); $drive3=mysql_result($result,$i,"drive3"); $drive4=mysql_result($result,$i,"drive4"); $drive5=mysql_result($result,$i,"drive5"); $drive6=mysql_result($result,$i,"drive6"); $drive7=mysql_result($result,$i,"drive7"); $drive8=mysql_result($result,$i,"drive8"); $drive9=mysql_result($result,$i,"drive9"); $drive10=mysql_result($result,$i,"drive10"); $drive11=mysql_result($result,$i,"drive11"); $drive12=mysql_result($result,$i,"drive12"); $drive13=mysql_result($result,$i,"drive13"); $drive14=mysql_result($result,$i,"drive14"); $drive15=mysql_result($result,$i,"drive15"); $drive16=mysql_result($result,$i,"drive16"); $drive17=mysql_result($result,$i,"drive17"); $drive18=mysql_result($result,$i,"drive18"); $drive19=mysql_result($result,$i,"drive19"); $drive20=mysql_result($result,$i,"drive20"); $drive21=mysql_result($result,$i,"drive21"); $drive22=mysql_result($result,$i,"drive22"); $drive23=mysql_result($result,$i,"drive23"); $drive24=mysql_result($result,$i,"drive24"); $drive25=mysql_result($result,$i,"drive25"); $drive26=mysql_result($result,$i,"drive26"); $drive27=mysql_result($result,$i,"drive27"); $drive28=mysql_result($result,$i,"drive28"); $drive29=mysql_result($result,$i,"drive29"); $drive30=mysql_result($result,$i,"drive30"); $drive31=mysql_result($result,$i,"drive31"); $drive32=mysql_result($result,$i,"drive32"); $drive33=mysql_result($result,$i,"drive33"); $drive34=mysql_result($result,$i,"drive34"); $drive35=mysql_result($result,$i,"drive35"); $drive36=mysql_result($result,$i,"drive36"); $drive37=mysql_result($result,$i,"drive37"); $drive38=mysql_result($result,$i,"drive38"); $drive39=mysql_result($result,$i,"drive39"); $drive40=mysql_result($result,$i,"drive40"); $drive41=mysql_result($result,$i,"drive41"); $drive42=mysql_result($result,$i,"drive42"); $drive43=mysql_result($result,$i,"drive43"); $drive44=mysql_result($result,$i,"drive44"); $drive45=mysql_result($result,$i,"drive45"); $drive46=mysql_result($result,$i,"drive46"); $drive47=mysql_result($result,$i,"drive47"); $drive48=mysql_result($result,$i,"drive48"); $drive49=mysql_result($result,$i,"drive49"); $drive50=mysql_result($result,$i,"drive50"); $drive51=mysql_result($result,$i,"drive51"); $drive52=mysql_result($result,$i,"drive52"); $drive53=mysql_result($result,$i,"drive53"); $drive54=mysql_result($result,$i,"drive54"); $drive55=mysql_result($result,$i,"drive55"); $drive56=mysql_result($result,$i,"drive56"); $drive57=mysql_result($result,$i,"drive57"); $drive58=mysql_result($result,$i,"drive58"); $drive59=mysql_result($result,$i,"drive59"); $drive60=mysql_result($result,$i,"drive60"); $drive61=mysql_result($result,$i,"drive61"); $drive62=mysql_result($result,$i,"drive62"); $drive63=mysql_result($result,$i,"drive63"); $drive64=mysql_result($result,$i,"drive64"); $drive65=mysql_result($result,$i,"drive65"); $drive66=mysql_result($result,$i,"drive66"); $drive67=mysql_result($result,$i,"drive67"); $drive68=mysql_result($result,$i,"drive68"); $drive69=mysql_result($result,$i,"drive69"); $drive70=mysql_result($result,$i,"drive70"); $drive71=mysql_result($result,$i,"drive71"); $drive72=mysql_result($result,$i,"drive72"); $drive73=mysql_result($result,$i,"drive73"); $drive74=mysql_result($result,$i,"drive74"); $drive75=mysql_result($result,$i,"drive75"); $drive76=mysql_result($result,$i,"drive76"); $drive77=mysql_result($result,$i,"drive77"); $drive78=mysql_result($result,$i,"drive78"); $drive79=mysql_result($result,$i,"drive79"); $drive80=mysql_result($result,$i,"drive80"); ?> <div align="center"> <blink>Warning:</blink> Clicking delete will delete this sechedule (no going back once clicked) <table style="width 87%" border="1" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">The Schedule as of: <? echo $date; ?></th> <th><a href="/dominos/admin/delete2.php?urn=<? echo $urn; ?>"><input name='' type='button' value='Delete'/></a></th> <th><a href="../admin/emailit.php"><input type="button" value="Email" /></a></th> <th><a href="../test.php?urn=<? echo $urn; ?>"><input type="button" value="Edit"/></a></th> </tr> </table> <br /> <br /> <input type="text" name="date0" id="date0" value="<? echo $date0; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date1" id="date1" value="<?php echo $date1; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="trans" name="date2" id="date2" value="<?php echo $date2; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date3" id="date3" value="<?php echo $date3; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date4" id="date4" value="<?php echo $date4; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date5" id="date5" value="<?php echo $date5; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date6" id="date6" value="<?php echo $date6; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date7" id="date7" value="<?php echo $date7; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $day; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date1" id="date1" value="<?php echo $day1; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="trans" name="date2" id="date2" value="<?php echo $day2; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date3" id="date3" value="<?php echo $day3; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date4" id="date4" value="<?php echo $day4; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date5" id="date5" value="<?php echo $day5; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date6" id="date6" value="<?php echo $day6; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date7" id="date7" value="<?php echo $day7; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row1; ?>"size="12" maxlength="12" readonly="true"style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row2; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row3; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row4; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row5; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row6; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row7; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row8; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row9; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row10; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row11; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row12; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row13; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row14; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row15; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row16; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row17; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row18; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row19; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row20; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row21; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row22; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row23; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row24; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row25; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row26; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row27; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row28; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row29; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row30; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row31; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row32; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row33; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row34; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row35; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row36; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row37; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row38; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row39; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row40; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row41; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row42; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row43; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row44; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row45; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row46; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row47; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row48; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row50; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row51; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row52; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row53; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row54; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row55; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row56; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row57; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $row58; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row59; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row60; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row61; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row62; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row63; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row64; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $row65; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive1; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold" /> <input type="text" name="date0" id="date0" value="<? echo $drive2; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive3; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive4; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive5; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive6; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive7; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive8; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive9; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive10; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive11; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive12; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive13; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive14; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive15; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive16; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive17; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive18; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive19; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive20; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive21; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive22; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive23; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive24; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive25; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive26; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive27; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive28; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive29; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive30; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive31; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive32; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive33; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive34; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive35; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive36; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive37; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive38; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive39; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive40; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive41; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive42; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive43; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive44; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive45; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive46; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive47; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive48; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive49; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive50; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive51; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive52; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive53; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive54; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive55; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive56; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive57; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive58; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive59; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive60; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive61; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive62; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive63; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive64; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive65; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive66; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive67; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive68; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive69; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive70; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive71; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive72; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <input type="text" name="date0" id="date0" value="<? echo $drive73; ?>"size="12" maxlength="12" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive74; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive75; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive76; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive77; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive78; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive79; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <input type="text" name="date0" id="date0" value="<? echo $drive80; ?>"size="10" maxlength="10" readonly="true" style="font-weight:bold"/> <br /> <br /> <br /> <br /> <? $i++;} ?> Can anyone point out what's wrong with my feedback.php? It used to work fine and I don't think I did anything but it stopped working - i.e. I had it on a site which I never looked at and when I did look at it I noticed the rubbish written to the database had inexplicably stopped being written there some months ago..... since then I've tried to clean it up and use it elsewhere ( I'm a baby at php and most else) but I can't get it to go right. In this attempt it was giving me the dreaded 'headers already written..' error and I (after googling) took out all the blank space I could and extra comments and what not and stuck in some debugging prints for me and now I get no errors but I get nothing written to the database and no email sent to me. If anyone cares to look at it to help me out, here it is, warts and all, with just the names changed to protect the innocent. <? // mail it $mailto = 'med@yahoo.com' ; $subject = "Ploverpark Feedback Form" ; $formurl = "feedback.html" ; $errorurl = "error.html" ; $thankyouurl = "thankyou.html" ; $uself = 0; $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ; $username = $_POST['username'] ; $firstname = $_POST['firstname'] ; $email = $_POST['email'] ; $comments = $_POST['comments'] ; $secondname = $_POST['secondname'] ; $country = $_POST['country'] ; $phone = $_POST['phone'] ; // do write to database now--------------------------- $link = mysql_connect("mydb.com", "my_pkguest", "password") or die("Could not connect : " . mysql_error()); print "Connected successfully<p>"; $DB = "my_pkguest"; $table = "clients"; mysql_select_db($DB) or die ("Database $DB not select.." . mysql_error()); print "Successfully select the Database: $DB "; $query = "INSERT INTO $table(username,firstname,secondname,email,country,phone,comments) values('$username','$firstname','$secondname','$email','$country','$phone','$comments')"; print "Successfully inserted to table: $table "; //------------------------------------------------------ $http_referrer = getenv( "HTTP_REFERER" ); if (!isset($_POST['email'])) { header( "Location: $formurl" ); exit ; } print "Now past the if isset "; //if (empty($name) || empty($email) || empty($comments)) { // header( "Location: $errorurl" ); // exit ; //} if ( ereg( "[\r\n]", $username ) || ereg( "[\r\n]", $email ) ) { header( "Location: $errorurl" ); exit ; } print "Now past the if ereg "; if (get_magic_quotes_gpc()) { $comments = stripslashes( $comments ); } $messageproper = "This message was sent from:\n" . "$http_referrer\n" . "------------------------------------------------------------\n" . "UserName of sender: $username\n" . "Firstname of sender: $firstname\n" . "Secondname of sender : $secondname\n" . "Country of sender : $country\n" . "Phone number of sender: $phone\n" . "Email of sender: $email\n" . "------------------------- COMMENTS -------------------------\n\n" . $comments . "\n\n------------------------------------------------------------\n" ; print "Now past the messageproper "; mail($mailto, $subject, $messageproper, "From: \"$username\" <$email>" . $headersep . "Reply-To: \"$username\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.07" ); print "Now past the mail"; //header( "Location: $thankyouurl" ); // exit ; ?> Hello coders, I'm using this code to grab random results from a table and it works well but I need it to be a non-repeating event. Code: [Select] $offset_result = mysql_query( " SELECT FLOOR(RAND() * COUNT(*)) AS `offset` FROM `jobs_board` "); $offset_row = mysql_fetch_object( $offset_result ); $offset = $offset_row->offset; I'm using this query followed by the html which is a set of divs with inline echo statements for the various variables I've localised from the table. Then I'm repeating that process a number of times to create a small list (I wanted to use a single while loop but cant figure it out at the moment). Anways, how can I make it so each query is random but also not repeated? At the moment they are indeed random but sometimes one same entry will appear a number of times consecutively... Nice one guys, L-plate This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=312600.0 I spent several hours trying to figure this thing out. Thought I had it nailed, but still getting duplicate record entries into the MySQL DB when I do NOT want them.
Here's the plot:
People filling out the possible attendance form for a Ham Radio event *sometimes* bring a 2nd person (either a spouse or a friend). The 2nd person may, or may not, also has a Callsign which I need to put INSERT the same MySQL Callsign column. In any event, to also identify the 2nd person as coming 'with' the 1st person.
MOST of the attendees are individuals with NO 2nd person.
My entry form has these primary fields:
callsign
fullname
AND...
callsign2
fullname2
What I came up with was to process the MySQL INSERT for the primary callsign & fullname into their respective MySQL DB Columns (which works fine), and then........... immediately following the main Query INSERT, to do a substitution type thing depending on whether or not a form entry was made in the callsign2 field, AND/OR, the fullname2 field.
This partially works, but if there is ONLY a primary callsign and fullname in the form, I'm still getting a duplicate record entry which includes the callsign in the `with` column (which should ONLY take place IF there is a 2nd person indicated).
Confusing?
Here is what I have been wrestling with to try and accomplish the objective, and now my eyes are glazed over ;-(
// TRICKY PART HERE // If a 2nd Callsign AND a Fullname if ($callsign2 != ' ' && $fullname2 != ' ') { // Still make reference to the primary Callsign in the MySQL DB `with` column $with = $callsign; // Assignment to allow 2nd Callsign to be entered in the MySQL `callsign` column $callsign=$callsign2; $fullname=$fullname2; $sql="INSERT INTO `mytable` (`callsign`, `fullname`, `with`) VALUES ('$callsign', '$fullname', '$with')"; // If NO 2nd Callsign BUT a Fullname } elseif ($callsign2 = ' ' && $fullname2 != ' ') { // Make reference to the primary Callsign in the MySQL DB `with` column $with = $callsign; $callsign=$callsign2; $fullname=$fullname2; $sql="INSERT INTO `mytable` (`callsign`, `fullname`, `with`) VALUES ('$callsign', '$fullname', '$with')"; } else { // The only thing I could thing of to (hopefully) NOT make a 2nd entry // record in the MySQL DB IF there is NO 2nd person referenced $with = $callsign; } if (!mysqli_query($con,$sql)) { die('Error: ' . mysqli_error($con)); }This mostly works EXCEPT if only a single (primary) person entry. The recap the objetives: 1. If ONLY a primary/single person entry on the form: * callsign & fullname get INSERTed into the `callsign` and `fullname` columns in the DB as ONLY one record entry 2. If BOTH a primary and 2nd person on the form: A. IF the 2nd person has a Callsign, then the 2nd record entry would be: * callsign2 & fullname2 get INSERTed into the `callsign` & `fullname` columns in the 2nd DB as a separate record entry * callsign of the primary person also gets INSERTED into the `with` column in the same 2nd DB record entry B. IF the 2nd person does NOT have a callsign, then the 2nd record entry would be: * fullname2 gets INSERTed into the `fullname` column in the DB as a separate 2nd DB record entry * callsign of the primary person also gets INSERTED into the `with` column in the same 2nd DB record entry I obvioiusly have overlooked something, but just can't seem to figure it out at this point {SIGH}. Thanks for any enlightenment. -FreakingOUT Hi Friends, I am suffering with very serious problem, We have a deal selling website--Problem is that when someone buy a deal , they are getting 2 vouchers on bahalf of one while they are getting charged ones only [I am using authorized.net payment gateway]. for some reason Entry is inserting TWICE in MYSQL but it is not happening on every purchase, it happens once in 20 purchase (for example).... I have tried every possible effort but it still happens, anybody can show me helping hand please ? this is my partial code where I am inserting the voucher info : for($i=0; $i<$_SESSION['quHidden']; $i++): if($_SESSION['RecName'][$i]!=''):$IsGist="t";$GRName=$_SESSION['RecName'][$i];else:$IsGist="f";$GRName="";endif; $coupon_code=str_makerand("12", "12", "false", "false", "false"); $NCCod="#".$coupon_code; $download_path="dealcoupon.php?id=".$sql_coupon['deal_id']."&CRANCode=".$coupon_code; $DLContent[]="<a href=\"".$download_path."\" target=\"_blank\" style=\"font-family: Helvetica,Arial,sans-serif; color: rgb(9, 129, 190);font-size: 14px;\">Download Voucher: ".$NCCod."</a>"; mysql_query("INSERT INTO `tbl_purchase` ( `fld_buyerid` , `fld_dealid` , `fld_amount` , `fld_purchaseid`, `fld_subdate`, `fld_expdate`, `fld_quantity`, `fld_cardno`, `isGift`, `fld_RecName`) VALUES ( '".$_SESSION['usr_id']."', '".$sql_coupon['deal_id']."', '".$sql_coupon['deal_price']."', '$NCCod', '".time()."', '".$sql_coupon[deal_edate]."', '1', '".$_SESSION['x_card_num']."','".$IsGist."','".$GRName."')"); $CoupanArr[]=$NCCod; endfor; //--------------------------------------------------------------------- mysql_query("insert into tbl_vouemails set fld_did='".$sql_coupon['deal_id']."', fld_uid='".$_SESSION['usr_id']."', fld_voucher='".implode(",",$CoupanArr)."', fld_etime='".getPATime($sql_coupon[deal_edate])."', fld_subdate='".time()."', fld_VReceiver='".implode(",",$_SESSION['RecName'])."'"); What im trying to achieve is a user contact system, when the user types input in the textarea its saved in a database along with his userid on the site and the date, I have an admin side coded up where it retrieves the data, but there is no order. I want to have it display the most recent results on top. I have looked into this in the mysql manual, but you know how that is its so hard to make sense of anything in that damn manual. Im using a while loop to display the data. How can I achieve this? I am trying to set up a item entry page form.png: Upon submission it shows unsuccessful even though I have checked the fields on mysql table and seem to be good am I missing something? Code: [Select] <form action="" method="post" enctype="multipart/form-data" name="Product_Entry"> <TABLE> <TR> <TD>Product ID</TD><TD><input name="SKU_ProductID" value="<?php if (isset($_post['SKU_ProductID'])) echo $_POST['SKU_ProductID']; ?>" type="text" size="11" maxlength="11" /></TD> </TR> <TR> <TD>Merchant SKU ID</TD><TD><input name="SKU_MerchSKUID" value="<?php if (isset($_post['SKU_MerchSKUID'])) echo $_POST['SKU_MerchSKUID']; ?>" type="text" size="18" maxlength="30" /></TD> </TR> <TR> <TD>Game Title</TD><TD><input name="Game_Title" value="<?php if (isset($_post['Game_Title'])) echo $_POST['Game_Title']; ?>" type="text" size="40" maxlength="40" /></TD> </TR> <TR> <TD>Platform</TD><TD><input name="Platform" value="<?php if (isset($_post['Platform'])) echo $_POST['Platform']; ?>" type="text" size="20" maxlength="20" /></TD> </TR> <TR> <TD>Genre</TD><TD><input name="Genre" value="<?php if (isset($_post['Genre'])) echo $_POST['Genre']; ?>" type="text" size="11" maxlength="11" /></TD> </TR> <TR> <TD>Weight</TD><TD><input name="Weight" value="<?php if (isset($_post['Weight'])) echo $_POST['Weight']; ?>" type="text" size="7" maxlength="7" /></TD> </TR> <TR> <TD>Supplier</TD><TD><input name="Supplier" Value="<?php if (isset($_post['Supplier'])) echo $_POST['Supplier']; ?>" type="text" size="25" maxlength="25" /></TD> </TR> <TR> <TD>Suppliers Price</TD><TD><input name="Supplier_Price" value="<?php if (isset($_post['Supplier_Price'])) echo $_POST['Supplier_Price']; ?>" type="text" size="10" maxlength="12" /></TD> </TR> <TR> <TD>Cashback</TD><TD><input name="Cashback" value="<?php if (isset($_post['Cashback'])) echo $_POST['Cashback']; ?>" type="text" size="6" maxlength="8" /></TD> </TR> <TR> <TD>Cashback Amount</TD><TD><input name="Cashback_Amount" value="<?php if (isset($_post['Cashback_Amount'])) echo $_POST['Cashback_Amount']; ?>" type="text" size="7" maxlength="11" /></TD> </TR> <TR> <TD><input type="hidden" name="submitted" value="true"/></TD><TD><input name="Submit" type="submit" value="Add_Product" /></TD> </TR></form></TABLE> <?php # Product Entry $page_title = 'Product Entry'; if (isset($_POST['Submit'])) { $errors = array(); if (empty($_POST['SKU_ProductID'])) { $errors[] = 'Please enter Product ID.'; } else { $sid = trim($_POST['SKU_ProductID']); } if (empty($_POST['SKU_MerchSKUID'])) { $errors[] = 'Please enter Merchant SKU.'; } else { $mid = trim($_POST['SKU_MerchSKUID']); } if (empty($_POST['Game_Title'])) { $errors[] = 'Please enter Game Title.'; } else { $gt = trim($_POST['Game_Title']); } if (empty($_POST['Platform'])) { $errors[] = 'Please enter Platform.'; } else { $pl = trim($_POST['Platform']); } if (empty($_POST['Genre'])) { $errors[] = 'Please enter Genre.'; } else { $ge = trim($_POST['Genre']); } if (empty($_POST['Weight'])) { $errors[] = 'Please enter Weight.'; } else { $we = trim($_POST['Weight']); } if (empty($_POST['Supplier'])) { $errors[] = 'Please enter Supplier.'; } else { $sup = trim($_POST['Supplier']); } if (empty($_POST['Supplier_Price'])) { $errors[] = 'Please enter Supplier Price.'; } else { $sp = trim($_POST['Supplier_Price']); } if (empty($_POST['Cashback'])) { $errors[] = 'Please enter Cashback %.'; } else { $cb = trim($_POST['Cashback']); } if (empty($_POST['Cashback_Amount'])) { $errors[] = 'Please enter Cashback Amount.'; } else { $cba = trim($_POST['Cashback_Amount']); } if (empty($errors)) { require_once ('connect.php'); [b]$q = "INSERT INTO `Products` (`SKU_ProductID`, `SKU_MerchSKUID`, `Game_Title`, `Platform`, `Genre`, `Weight`, `Supplier`, `Supplier_Price`, `Cashback`, `Cashback_Amount`) VALUES ('$sid', '$mid', '$gt', '$pl', '$ge', '$we', '$sup', '$sp', '$cb', '$cba')"; $r = @mysql_query ($dbc, $q); if ($r) { // If it ran OK. // Print a message: echo '<h1>Thank you!</h1> <p>Product Inserted!</p><p><br /></p>'; } else { // If it did not run OK. // Public message: echo '<h1>System Error</h1> <p class="error">You could not be registered due to a system error. We apologize for any inconvenience.</p>'; // Debugging message: echo '<p>' . mysqli_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } // End of if ($r) IF. mysqli_close($dbc); // Close the database connection.[/b] // Include the footer and quit the script: include ('includes/footer.html'); exit(); } else { echo '<H1>Error!</H1> <p class="error">The Following error(s) occurred:<br />'; foreach ($errors as $msg) { echo " - $msg<br />\n"; } echo '</p><p>Please try again.</p><p><br /></p>'; } } ?> If there is anything else needed let me know I have a bad way with words, so if the title doesnt make much sense nor my post, I apolagize! But I am using a while loop and mysql_fetch_array to echo all information in a table in mysql. With each entry, I have included a button that executes a delete query for that entry. Code: [Select] $delquery="DELETE FROM requests WHERE user = '".$row['user']."'"; mysql_query($delquery,$link2); echo "<font size='19px' color='#009933'>User deleted from request database.When I click the button, the message is echod in every entry listed on the page, and nothing happens. I figured Id use delete from the username, so that way mysql will know which one to delete... but Idk when I think about it thats dumb and makes no sense. Im stuck. This side of the application im trying to make is the admin side where I can process requests. After I process the request I delete it from the database so I know I processed it. I have no idea what query to use for this. Anybody know how I could do this? Thanks To get current date and time I use: $date = date("d-M-Y h:i:s"); But how can I get date and time which was before 5 minutes. |