Jump to content

theflea912

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Contact Methods

  • AIM
    theflea912
  • MSN
    theflea912@gmail.com
  • Website URL
    http://www.qantas.uselessmachinima.com

Profile Information

  • Gender
    Not Telling

theflea912's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I have a table that contains workout data. The results will be displayed in a table, ordered by date_rowed column, but only take 15 entries. (I have also tried ordering by the id column, which should indicate order as well). Problem is, every time I use this query: $workoutsql = "SELECT * FROM workouts WHERE rowerid='$profile' ORDER BY 'date_rowed' DESC LIMIT 15"; It displays 15 entries; just in the ASC order. I have tried everything I know. Removed DESC, tried ASC, and removed the LIMIT flag; this was the odd one, as when I did this, it ordered it correctly, but displayed ALL the entries. I have also used the id column as well but got the same thing. I have never encountered this behavior before. date_rowed = xxxx-xx-xx num = auto incrementing integer <?php while($row6 = mysql_fetch_array($workoutdata)){ $split = split_calc("$row6[time]","$row6[distance]"); $adjusted_time = format_time("$row6[time]", "$display_format[time_format]"); echo "<tr><td class=\"tablecells\">$row6[date_rowed]</td><td class=\"tablecells\">$row6[distance]m</td><td class=\"tablecells\">$adjusted_time</td><td class=\"tablecells\">$split</td><td class=\"tablecells\">$row6[comments]</td></tr>"; } ?> Obviously, I am missing something here; there is no rule regarding ordering and limiting as far as know. Any help would be greatly appreciated.
  2. haha it is now working. Like I said, Javascript is not my thing. Thanks man. I don't know how to "solve" this thread, so maybe a mod or admin can do that...?
  3. Here is the code now: <script type="text/javascript"> window.onload = function(){ // fetch the submit button element by id submitButton = document.getElementById('submit'); // add an event to the submit button submitButton.onclick = function(){ var xmlhttp; function pace(hour,min,sec,msec,distance){ xmlhttp=GetXmlHttpObject(); if (xmlhttp==null){ alert ("Browser does not support HTTP Request"); return; } var url="calc_split.php"; url=url+"?hour="+hour; url=url+"&min="+min; url=url+"&sec="+sec; url=url+"?msec="+msec; url=url+"?distance="+distance; url=url+"&sid="+Math.random(); xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function stateChanged(){ if (xmlhttp.readyState==4){ document.getElementById("split").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject(){ if (window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject){ // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } } } </script> <form onsubmit="return false;"> <table width="100%"> <tr> <td class="tablecells" align="right"><strong>Time</strong> <input name="hour" type="text" size="2" maxlength="2" /><strong>:</strong><input name="minute" type="text" size="2" maxlength="2" /><strong>:</strong><input name="sec" type="text" size="2" maxlength="2" /><strong>.</strong><input name="msc" type="text" size="1" maxlength="1" /></td> <td class="tablecells"> / <strong>Distance</strong><input type="text" name="distance" size="6" maxlength="6"/></td> <td class="tablecells" align="center"><input type="submit" value="Calculate" id="submit"/></td> </tr> </table> </form> Again thanks for your help. I have already tried googling it; I do not like bothering people with simple questions like these. However, none of them tell me what to do in my situation, especially, since you had me put the function, inside of the function.
  4. Thanks for your help. Like I said before, I am very limited in my javascript knowledge. But wouldn't this code just send the submit button? Or does it also send all the fields in the form, because it is not working.
  5. Very simple question actually. I am just starting using AJAX so I am not quite sure how to do this. I have 5 text fields inside a form. I need to pass those to a script via AJAX. I have been trying to use onsubmit, but it doesn't actually do it; it instead reloads the page with the variables set in the url. Here is the code for the script itself and the form code. <script type="text/javascript"> var xmlhttp; function pace(hour,min,sec,msec){ xmlhttp=GetXmlHttpObject(); if (xmlhttp==null){ alert ("Browser does not support HTTP Request"); return; } var url="calc_split.php"; url=url+"?hour="+hour; url=url+"&min="+min; url=url+"&sec="+sec; url=url+"?msec="+msec; url=url+"&sid="+Math.random(); xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); } function stateChanged(){ if (xmlhttp.readyState==4){ document.getElementById("split").innerHTML=xmlhttp.responseText; } } function GetXmlHttpObject(){ if (window.XMLHttpRequest){ // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject){ // code for IE6, IE5 return new ActiveXObject("Microsoft.XMLHTTP"); } return null; } </script> HTML Code: <form id="240" onsubmit="pace(this.id)"> <table width="100%"> <tr> <td class="tablecells" align="right"><strong>Time</strong> <input name="hour" type="text" size="2" maxlength="2" /><strong>:</strong><input name="minute" type="text" size="2" maxlength="2" /><strong>:</strong><input name="sec" type="text" size="2" maxlength="2" /><strong>.</strong><input name="msc" type="text" size="1" maxlength="1" /></td> <td class="tablecells"> / <strong>Distance</strong><input type="text" name="distance" size="6" maxlength="6"/></td> <td class="tablecells" align="center"><input type="submit" value="Calculate" /></td> </tr> </table> </form> When I click Calculate, it just reloads the page, not actually doing the AJAXy goodness. What is wrong?
  6. Thanks for the quick response. I edited the SQL from one of the examples to: $new = "SELECT count(*) AS rank FROM (SELECT * FROM workouts WHERE distance='$distance_of' AND ranked='Yes' > (SELECT * FROM workouts WHERE rowerid='$userid_func' AND distance='$distance_of' AND ranked='Yes') ORDER BY time ASC)AS s"; When I run it though, I get "Operand should contain 1 column(s)". I do not know SQL really all that well, so can someone explain what is going on?
  7. The title doesn't really provide enough of a description. I know PHP well enough that I could select an entry via WHERE and LIMIT clause. Here is the problem: I have a bunch of entries in a table, sorted by time (ASC so the "winning" time is the first entry). I need to find a users entry in that list and return its placement. So if they got 3rd place out of 5 people, it would return a 3, and so on. I have no idea how to do this. My first idea was to combine each row into an array, and than do array_search for the ID of the user, but that didn't work. How would you go about doing this?
  8. Yeah I tried that. One problem, it doesn't work. Heres the code now: [code] <?php //begining of the conversion to variables $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $userid = $_POST['userid']; $comments = $_POST['comments']; $hiredate = date("Y-m-d"); //db connection stuff $link = mysql_connect("mysql18.powweb.com","theflea912","**********"); mysql_select_db("qantasvaforums",$link); //Insert pilots $query=mysql_query("INSERT INTO pilot (fname, lname, email, userid, comments, hiredate) values ('$fname', '$lname','$email','$userid','$comments','$hiredate' )"); $query = mysql_query($query); $res = mysql_result($result); //Error Reporting if (!$res) { echo "Error " . mysql_errno() . " in SQL "; echo "<PRE>$sql</PRE>"; echo mysql_error; exit; } ?> [/code]
  9. Ok so I have this form that submits the data entered into a database. I have double and triple checked the simple things such as names of fields, names of variables, etc. And yet I still get this error 1065 whih looks like this: [b]Error: 1065 SQLSTATE: 42000 (ER_EMPTY_QUERY) Message: Query was empty [/b] [code] <?php //begining of the conversion to variables $fname = $_POST['fname']; $lname = $_POST['lname']; $email = $_POST['email']; $userid = $_POST['userid']; $comments = $_POST['comments']; $hiredate = date("Y-m-d"); //db connection stuff $link = mysql_connect("mysql18.powweb.com","theflea912","**********"); mysql_select_db("qantasvaforums",$link); //Insert pilots $query=mysql_result("INSERT INTO pilot (fname, lname, email, userid, comments, hiredate) values ('$fname', '$lname','$email','$userid','$comments','$hiredate' )"); $query=mysql_query($query); $result=mysql_result($result); if (!$res) { echo "Error " . mysql_errno() . " in SQL "; echo "<PRE>$sql</PRE>"; echo mysql_error; exit; } ?> [/code] So what is wrong?
  10. Let me try posting again because me last post couldn't be found or whatever. So I have a form. I than have a script that mails me the form. The script looks like this: An email has been sent to the Director of Human Resources. Thank you for apply, you will hear back in a bit. <?php $body = "Application Alert!\n\n"; foreach($_POST as $field => $value) { $body .= sprintf("%s = %s\n", $field, $value); } mail("theflea912@gmail.com", "APPLYING PILOT!", $body, 'From: "APPLY" <apply@qantasva.com'); ?> My friend at least acts like he knows what he is doing, and told me that somebody could delete all the files on the webserver by useing a UNIX command. Is this true?
  11. I recently wrote a script that emails the form results to me. I also have a friend who at least acts like he knows PHP and when he looked at the code he said that a command could be entered that would delete the files on the server or on the computor. Is this true? If so, is there a way to correct it or prevent it. The code is below: ------------------------------------------------------------------------ An email has been sent to the Director of Human Resources. Thank you for apply, you will hear back in a bit. <?php $body = "Application Alert!\n\n"; foreach($_POST as $field => $value) { $body .= sprintf("%s = %s\n", $field, $value); } mail("theflea912@gmail.com", "APPLYING PILOT!", $body, 'From: "APPLY" <apply@qantasva.com'); ?>
×
×
  • 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.