Psycho
Moderators-
Posts
12,159 -
Joined
-
Last visited
-
Days Won
130
Everything posted by Psycho
-
I think your query is messed up. The select list is to select the season (named 'users'), but you use the post value 'q' as the ID from the rankings table. I suspect the ID is a unique identifier for each team? Can't be sure without knowing your database structure, but I think you should be using the season value something like this: $season_id = mysql_real_escape_string($_POST['users']); $sql="SELECT * FROM rankings WHERE season_id = '{$season_id}'"; Also, you should fix the opening TR tag for your headings.
-
Here is your code modified to have the logic all at the top of the page and only output data to the browser if it should. There may be some typos as I have not tested this. <?php session_start(); // User chooses group to edit parts/features/spec tips/to order in. require_once('navmenu.php'); require_once('connectvars.php'); require_once('constants.php'); // Connect to the database $dbc = mysqli_connect($host, $user, $password, $database); $errcnt=0; if (isset($_POST['cmdEdit'])) //Try to save items first. { $error_msg = ''; //First get GID based on cbxGroupname. $s=$_POST['cbxGroupname']; $arr=explode('#',$s); $gname=$arr[0]; //Group name $basemodel=$arr[1]; $query="SELECT grid, groupname FROM hgroup WHERE groupname='{$gname}' AND basemodel='{$basemodel}';"; $result=mysqli_query($dbc, $query); if (!$result) { $error_msg = mysql_error().'<br/>'.$query; } else if (mysqli_num_rows($result)>1) { $error_msg = "ERROR: There was more than one group selected. Cannot save data.<br/>{$query}"; } else { $row = mysqli_fetch_array($result); $grid=trim($row['grid']); //Group id. Stored on other tables also. $_SESSION['grid']=$grid; $home='http://'.$SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']).'/editpart.php'; header('Location: '.$home); exit(); } } //if isset($_POST['submit'] $error_msg2 = ''; $query = "SELECT grid, groupname, basemodel FROM hgroup ORDER BY groupname;"; $result = mysqli_query($dbc,$query); if (!$result) { $error_msg2 = mysql_error().'<br/>'.$query; } elseif (mysqli_num_rows($result)<1) { $error_msg2 = "ERROR: No groups selected: {$query}"; } else { //Create combo box options showing all group names. $options = ''; $selected = ' selected="selected"'; while ($row = mysqli_fetch_array($result)) { $value = $row['groupname'].'#'.$row['basemodel']; $options .= "<option value=\"{$value}\"{$selected}>{$value}</option>\n"; $selected = ''; } } mysqli_close($dbc); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Edit Part Search Screen</title> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <body> <p class="error"><?php echo $error_msg; ?></p> <h2>Proto3: Product/Part Edit Search v.10b</h2> <p>This screen is used to search for existing groups, and their associated products, to edit. <!--------------------------------------------------------> <form action="<?php echo $_SERVER['PHP_SELF'].'?'.SID; ?>" method="post"> <hr/> <label for="cbxGroupname">Group name</label> <select name="cbxGroupname"> <?php echo $options; ?> </select> <p class="error"><?php echo $error_msg2; ?></p> <p>Commands: <input type="submit" name="cmdEdit" value="Edit"></p> </form> </body> </html>
-
No that is NOT what you need to do. You need to look at the problem logically and proceed accordingly. You cannot submit a header() request after you have sent data to the browser. So, just do as has already been explained. Process the data first THEN either send to another page or output content from the current script.
-
<?php $qres = mysql_query("SELECT * FROM `$clubprefix"."_player` WHERE id='$id'"); //Start table and create table headers $results = "<table>\n"; $results .= "<tr>\n"; $results .= "<th>Forehand/Backhand</th>\n"; $results .= "<th>Fitness/Movement</th>\n"; $results .= "<th>Serve/Return</th>\n"; $results .= "<th>Volley</th>\n"; $results .= "<th>Special Shots</th>\n"; $results .= "<th>Playing Style</th>\n"; $results .= "<th>Tournament Experience</th>\n"; $results .= "</tr>\n"; //Output the data WHILE ($row = mysql_fetch_array ($qres, MYSQL_ASSOC)) { $results .= "<tr>\n"; $results .= "<td>{$row['FB']}</td>\n"; $results .= "<td>{$row['FM']}</td>\n"; $results .= "<td>{$row['SR']}</td>\n"; $results .= "<td>{$row['Vol']}</td>\n"; $results .= "<td>{$row['SS']}</td>\n"; $results .= "<td>{$row['PS']}</td>\n"; $results .= "<td>{$row['TE']}</td>\n"; $results .= "</tr>\n"; } //Close the table $results .= "</table>\n"; ?> <html> <head></head> <body> <div id="tableOutput"> <?php echo $results; ?> </div> </body> </html> I put the results in a variable as it is better form to include the logic at the top of your page and display the results in the body of the page.
-
Just create a function function clearZero($value) { return ($value==0) ? '' : $value; } Then use that function when assigning the values to your variables: $variable = clearZero($_POST['fieldName']);
-
Change this echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=$next'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?&pagenum=$last'>Last ->></a> "; To this: echo " <a href='{$_SERVER['PHP_SELF']}?gid={$gid}&pagenum={$next}'>Next -></a> "; echo " "; echo " <a href='{$_SERVER['PHP_SELF']}?gid={$gid}&pagenum={$last}'>Last ->></a> ";
-
You mean "find a class or some third-party plug-in"? http://lmgtfy.com/?q=php+edit+word+doc
-
Yeah, teamtonic is right. You happened to pick one very unique case where using curly braces would not give you what you were looking for. In that particular case, you could omit the curly braces to get the output you were after. Here is an example where you would want to use the curly braces. Example: Let's say the application uses the user's first and last name with an underscore between them to autogenerate a folder name to store a user's data. If you wanted to display the folder name on the screen, this would not work: $first = 'Dave'; $last = 'Smith'; echo "$first_$last"; //Output: Smith That would try to echo the variables $first_ and $last. The variable $first_ doesn't exist and you would only be displaying the last name. Instead you could do this: $first = 'Dave'; $last = 'Smith'; echo "{$first}_{$last}"; //Output: Dave_Smith
-
Use double equals for comparison. A single equal sign is used for assignment
-
It depends on hos the position is defined and what you are really after. If you have specified the position using in-line CSS properties OR if you have defined the CSS property using javascript, then you can get the value using javascript. If, however, the property is defined in a stylesheet, then javascript cannot get the value. You could probably write some really complext code to get the class or ID from the element and then read the stylesheet to find the appropriate class, and finally parse the properties of the class to find the position. But, that would be a lot of work. Also, if the position is not even defined in the style properties and you are just trying to get the position that can be done, but there are browser compatability issues to contend with. There are some freely available scripts that can do this if you do a littel searching. Anyway, here is an example script that gives four different examples of how the left property is defined. The sample javascript function can obtain the left position for two, but not the other two. <html> <head> <style> #div3 { position: absolute; left:400px; } </style> <script> function test(divID) { var divObj = document.getElementById(divID); alert( divObj.style.left ); } </script> </head> <body> <div id="div1" style="">One - No position defined</div> <div id="div2" style="position:absolute; left:150;">Two - Defined In Line</div> <div id="div3">Three - Defined in style sheet</div> <div id="div4" style="position:absolute;">Four - Defined via javascript</div> <br /><br /><br /> <button onclick="test('div1');">One</button><br /> <button onclick="test('div2');">Two</button><br /> <button onclick="test('div3');">Three</button><br /> <button onclick="test('div4');">Three</button><br /> <script type="text/javascript"> document.getElementById('div4').style.left = '600px'; </script> </body> </html>
-
Word docs are not plain text documents. You can't simply "write" text to the dcoument. Prior to Office 2007 word docs were stored in a proprietary format. Starting with 2007 they are being stored in an XML format. You will need to write the data in a format that is appropriate to the document you have. I think your only option is going to be to find a class or some third-party plug-in that allows you to modify word documents.
-
Yeah, I use both single and double as my preference depending on the context. If I want to include variables in the string I alomst always use double quotes and include the varaibles within curly braces to make it apparent that the value is a variable. The braces also prevent the variable from being misinterpreted if other characters must reside right next to the variable. $salutaion= "Hello {$username}!"; However, if there are no variables in the string, and especially if it will have HTML tags, I will use single quotes so I don't have to escape the double quotes int he HTML code $img= "<img src="pathtofile/logo.gif" />";
-
Personal preference. There are also the heredoc and nowdoc methods of defining variables. I suggest you take a look at this page: http://php.net/manual/en/language.types.string.php
-
You can put whatever you want into the variables. Whatever you put in it will get used. If you know how to write the HTML code for an image, just include it into the testimonial string. The only thing to watch for is quotation marks. If you define a string with double quotation marks and you want to use double quotation marks in the string, you will need to escpe them (same goes for single quotation marks: $testimonials = array( "<h3><a href=\"http://www.eastindia.com\">Mr Kibir Rahman T/A East India Trading Company</a></h3> <img src=\"http://www.eastindia.com\logo.gif\"> <P>'Since opening our 5 restaurants you have really helped us.'<P>", "<h3>Steve Bird T/A 1 Stop Magic Carpets</h3><p>'I would like to thank your member of staff for helping me'<P> ", );
-
Well, it worked for me. I actually tested that code before I posted. Since you didn't take the time to post the actual error (with the line numbers) and the relevant code, there's nothing I can do to help.
-
siric is correct, there is no reason you cannot put a loop within another loop. However, in this case, the inside WHILE loop is completely unnecessary and is just a complete waste. The loop is processign the exact same records every time. I think you meant to get the sub-category options respective to each parent option. But, the real reason you are not getting any results is you are using the first query when you meant to run the second query $result2 = dbQuery($sql); //<< you menat to use $sql2 But, you can get all the data you need with a single query - which would be a much better approach.
-
Javascript parseInt(string, radix) always return NaN
Psycho replied to Joshua4550's topic in Javascript Help
Fixed typo: function convertBase(input, input_base, output_base) { var inputInDec = parseInt(input, input_base); var output = inputInDec.toString(output_base); return output; } -
Javascript parseInt(string, radix) always return NaN
Psycho replied to Joshua4550's topic in Javascript Help
Try this function convertBase(input, input_base, output_base) { var inputInDec = parseInt(input, input_base); var output = inputInDec.toString(ouput_base); return output; } -
Javascript parseInt(string, radix) always return NaN
Psycho replied to Joshua4550's topic in Javascript Help
Why don't you start by explaining what you want to achieve? Your first post was only regarding the NaN error you were receiving. I can "assume" you are trying to convert a base 10 number to a base 2, but that is only a guess since you've never stated that. Your last post you state you see no errors but don't state what you want the script to do and what it is doing differently. -
Javascript parseInt(string, radix) always return NaN
Psycho replied to Joshua4550's topic in Javascript Help
I think you are misunderstanding the purpose of the second parameter for parseInt(). If you specify the radix to be 2, then the value to be parsed must be in the format of a binary number, e.g. "1101" (which would be parsed to the decimal value of 13). -
That is not what you requested. You stated you wanted to show the 5 pages before and the 5 pages after the current page. I only hard coded the current page for illustrative purposes. It is your responsibility to define the current page, the max pages (i.e. limit) and the span (which you already stated would be 5, but the code will allow for different values if you wish. This foum uses more complex functionality to include, possibly, the very first and very last pages and ellipses as needed. You did not ask for that, so I did not provide it.
-
<?php $current_page = 9; $span_pages = 5; $start_page = (($current_page-5) < 1) ? 1 : ($current_page-5); $end_page = (($current_page+5) > $limit) ? $limit : ($current_page+5); for($page=$start_page; $page<=$end_page; $page++) { if($page==$current_page) { echo "| <b>{{$page}}</b> | "; } else { echo "| <a href=\"?start={$page}\">{$page}</a> | "; } } ?>
-
I think you need a NAME for your input fields. Don't think jsut an ID will work
-
Here's something I have laying around <?php //bbcode $patterns = array( //BB Code "/\[[b]\](.*?)\[\/b\]/is", "/\[[i]\](.*?)\[\/i\]/is", "/\[[u]\](.*?)\[\/u\]/is", "/\[[s]\](.*?)\[\/s\]/is", "/\[marquee\](.*?)\[\/marquee\]/is", "/\[url\](.*?)\[\/url\]/is", "/\[url=(.*?)\](.*?)\[\/url\]/is", "/\[img\](.*?)\[\/img\]/is", "/\[quote\](.*?)\[\/quote\]/is", "/\[code\](.*?)\[\/code\]/is", "/\[(size|color)=(.*?)\](.*?)\[\/\\1\]/is", "/\[br\]/i", //Emoticons "/ \:\) /", "/ \:\( /", "/ \ /", "/ \ /", "/ \:\| /", "/ \ /", "/ \:\? /", "/ \;\) /"); $replacements = array( //BB Code "<b>\\1</b>", "<i>\\1</i>", "<u>\\1</u>", "<s>\\1</s>", "<marquee>\\1</marquee>", "<a href=\"\\1\">\\1</a>", "<a href=\"\\1\" target=\"_blank\">\\2</a>", "<img border=\"0\" src=\"\\1\">", "<div><b>Quote:</b> <i>\\1</i></div>", "<br /><b>Code:</b><br /><div style=\"overflow:auto;\"><xmp>\\1</xmp></div><br />", "<font \\1=\"\\2\">\\3</font>", "<br />", //Emoticons " <img src=\"smilies/happy.gif\" border=\"0\"> ", " <img src=\"smilies/angry.gif\" border=\"0\"> ", " <img src=\"smilies/omg.gif\" border=\"0\"> ", " <img src=\"smilies/tounge.gif\" border=\"0\"> ", " <img src=\"smilies/dry.gif\" border=\"0\"> ", " <img src=\"smilies/biggrin.gif\" border=\"0\"> ", " <img src=\"smilies/confused.gif\" border=\"0\"> ", " <img src=\"smilies/wink.gif\" border=\"0\"> " ); $string = "[b]This is bold text[/b] [i]this is italic text[/i] [b][i]This is bold, italic text[/b][/i]"; $result = preg_replace($patterns,$replacements,$string); echo $result; ?>[/ode]
-
Insert Date from PHP form into MySQL date column
Psycho replied to mtnmchgrl's topic in PHP Coding Help
One quick thing I don't understand.....below where the HTML form comment is and there is a form method post statement.... <form method="post" action="">addTournament2.php How come the .php file is outside of the form method brackets?? How does that work? Everything else for the most part makes sense and its definitely in a hell of a lot more organized fashion. Perhaps as I become better at this I will be able to produce something similiar. Sigh. Sorry, bout that. I removed the file name from the action so I could have the page POST to itself for testing purposes. You can replace that value or leave it blank if the page is supposed top post to itself. // PROCESS FORM ON SUBMIT $response = ''; if (isset($_POST['tourneyName'])) No, no relation. In that code, I simply define $respons as an empty string in case it doesn't get defined later. The IF statement is there to process the data only if data was posted.