jcbones
Staff Alumni-
Posts
2,653 -
Joined
-
Last visited
-
Days Won
8
Everything posted by jcbones
-
Well you need to explain what you want, clearly.
-
check if a post variable is the only one in $_POST
jcbones replied to Omzy's topic in PHP Coding Help
If you submit the same information to MySQL, it will not overwrite that column. It will only overwrite columns that are not the same. IIRC. MySQL Update Syntax -
Login works on Firefox, but not other browsers.
jcbones replied to -Karl-'s topic in PHP Coding Help
Notice: Undefined variable: visit in: Optometrist/lesson.php -
In your diagram, you don't have anything grouped by the varset column. If they were grouped, then all the 1's would be at the top or the bottom. SELECT * FROM table GROUP BY varset ASC;
-
I have used fusion charts before, and they work pretty good. They do have a free version that might work for you. Google-Fusion Charts
-
Why don't you change your array, so the groupname would be the main key. Like: Array ( [Admin] => Array ( [username] => IchBin [name] => IchBin [posts] => 12975 [location] => [href] => link here [link] => IchBin [blurb] => [avatar] => Array ( [name] => [image] => [href] => [url] => ) [last_login] => Today at 04:19:43 PM [last_login_timestamp] => 1278886783 [website] => Array ( [title] => [url] => ) [online] => Array ( [is_online] => 1278886783 [text] => [image_href] => link here ) ) [support] => Array ( [username] => Stu [name] => Stu [posts] => 2713 [location] => Laville [href] => link here [link] => Stu [blurb] => [avatar] => Array ( [name] => [image] => [href] => link here [url] => ) [last_login] => Today at 04:07:38 PM [last_login_timestamp] => 1278886058 [website] => Array ( [title] => Our Site [url] => http://www.website.org ) [online] => Array ( [is_online] => 1278886075 [text] => [image_href] => link here ) ) )
-
Try: SELECT t.team_id, t.team_name, COUNT( r.league_match_result_id ) AS 'team_matches_played', COUNT( CASE r.result WHEN 'Win' THEN 1 END ) AS 'team_wins', COUNT( CASE r.result WHEN 'Draw' THEN 1 END ) AS 'team_draws', COUNT( CASE r.result WHEN 'Loss' THEN 1 END ) AS 'team_losses' FROM teams t LEFT JOIN league_match_results r ON t.team_id = r.team_id GROUP BY t.team_id ORDER BY team_wins DESC, team_draws DESC It might not make a difference, but it is correct, as you are wanting to count and not change the column.
-
I don't think his table has columns "win", "loss", or "draw". Rather I think the table column "results" contain those values. You may need a CASE for this to work. UN-TESTED SELECT t.team_id, t.team_name, COUNT(r.result_id) as 'team_points', COUNT(CASE r.results WHEN 'win' THEN 'team_wins' WHEN 'loss' THEN 'team_losses' ELSE 'team_draws' END) FROM teams t LEFT JOIN results r ON t.team_id = r.team_id GROUP BY t.team_id ORDER BY team_points DESC
-
You are opening a bracket on line 137, but have failed to close it. Here elseif ($client_name == 'admin') {
-
You could build the query, where it would combine only the selected parameters. Such as: -UNTESTED <?php foreach($_POST as $key => $value) { $v = strtolower($value); if($v != 'reel manufacturer' || $v != 'scale' || $v != 'kit manufacturer' || $v != 'vehicules year manufactured') { //This kills the value being passed, if nothing was selected. $where[] = $key . ' = \'' . $value . '\''; } } if(!empty($where)) { $where = implode(' AND ',$where); $sql = "SELECT * FROM kit WHERE $where "; $nt = mysql_query($sql); } else { echo 'You need to select at least one parameter!'; } ?>
-
To do it via PHP, something like this should work. <?php if(isset($_POST['submit'])) { //execute only if an item is posted. $name = preg_replace('~([^a-zA-Z])~','',$_POST['name']) . "\n"; //strip out all but alpha characters in the posted name. $file = fopen('names.txt','a'); //open file('names.txt') or create if it doesn't exist. fwrite($file,$name); //write the name to the end of the file. fclose($file); //close the file. } echo implode('<br />',file('names.txt')); //print the contents to the page, one name per line. ?> <form action="" method="post"> <label>Name: </label><br /> <input type="text" name="name" value="" /><br /> <input type="submit" name="submit" value=" Submit " /> </form> *modified for newline.
-
Try: if(isset($_POST)) { imgprocess(img1); imgprocess(img2); imgprocess(img3); imgprocess(img4); }
-
Search script working but mysql_fetch_array error!
jcbones replied to McMaster's topic in PHP Coding Help
There is alot of redundancy in that code. Over 1/3 of it can be cut out. Unless I missed something. This should return what you want. <?php $var = addslashes($_POST['query']); $trimmed = trim($var); $trimmed_array = explode(" ",$trimmed); foreach ($trimmed_array as $trimm){ $query = "SELECT * FROM help_topics WHERE topic LIKE '%$trimm%' OR text like '%$trimm%'"; $numresults = mysql_query ($query); $row_num_links_main = mysql_num_rows($numresults); if($row_num_links_main > 0) { while( $row= mysql_fetch_array($numresults)){ <ul style="margin-bottom: 0pt;"> <?php echo "<li><a href=\"http://www.website.com/help_topic.php?id=".$row['id']."\">".$row['topic'] ."</a></li>"; ?> </ul> <?php } } } ?> -
Try using in_array() <?php $query="select column_name fldnm, column_comment fldcomment from information_schema.columns where table_name='burial_listing' and column_name not in ('dod','id')"; $result = mysql_query($query) or die(mysql_error()); while($row = mysql_fetch_array($result)) { $checked = (isset($_POST['items']) && in_array($row['fldnm'],$_POST['items'])) ? ' checked="checked"' : NULL; echo '<input type="checkbox" name="items[]" value = "'.$row["fldnm"].'" ' . $checked . '>'.$row["fldcomment"]."<br>"; } ?>
-
$sql = "SELECT * FROM wp_posts WHERE post_type = 'post' AND post_status IN ( 'draft', 'publish', 'future', 'pending', 'private' ) ORDER BY post_date DESC LIMIT $limit"; if(!$result = $mysqli->query($sql)) { die("Error in $sql <br />" . $mysqli->error); }
-
Try changing the file permission to 0600 This give the file owner read and write, and everyone else nothing.
-
OK, couple of things. The script is looking at your display format, Currently you have it set to seconds, so if you enter in more than 60 seconds, it will loop until the counter reaches 0. You can see this if you set the variable to: DisplayFormat = " %%M%% Minutes %%S%% Seconds"; You would also need to make sure that your variable $s is an integer. $s = (int)$_GET['s']; //or $s = int_val($_GET['s']);
-
Your $pend should not change. The limit on a query is set to: LIMIT $row_start, $number_of_rows Try changing your $_GET['page'] to the $pend variable.
-
while($a < 17){ echo '<input type="checkbox" name="delete[' . $a . ']" id="delete[' . $a . ']" value="00001" /> $a++; } foreach($_POST['delete'] as $key => $value) { $delete[$key] = $value; } echo '<pre>'; print_r($delete); echo '</pre>';
-
Your problem is here: for($i=$firstDay['wday'];$i<=7;$i++){ $actday++; load_events($actday, $month); } Your variable $firstDay['wday'] holds a value from 0(Sunday) - 6(Saturday). This loop is fine while the month starts on any day but Sunday, which would assign the $i = 0, making the count of ($i<=7) = 8; The simple fix for this would be to add this line: // Display the first calendar row with correct positioning echo '<tr>'; //ADD THIS LINE: $firstDay['wday'] = ($firstDay['wday'] == 0) ? 7 : $firstDay['wday']; //This will change the firstDay['wday'] variable to 7 if it's inital value is 0. for($i=1;$i<$firstDay['wday'];$i++){ echo '<td> </td>'; } That is all that I see.
-
Showing the number of SQL Queries generated with PHP
jcbones replied to sw0o0sh's topic in PHP Coding Help
Something like: //Top of page. $start = microtime(true); $queryCount = 0; mysql_query($sql); ++$queryCount; mysql_query($sql); ++$queryCount; $end = microtime(true); echo 'Page created in ' . ($end - $start) . ' seconds, with ' . $queryCount . ' Queries.'; -
A few of things. 1. Make sure you have a connection script in the same directory, named connect.php It should look something like: <?php // ******** EDIT CONNECTION INFORMATION BELOW ************ $hostname = "localhost"; $database = "test"; $username = "root"; $password = ""; // *********** END EDIT CONNECTION INFORMATION ************ $con = mysql_connect($hostname, $username, $password); mysql_select_db($database, $con); ?> 2. You can then include the current script in any other page by using. include('count.php'); //Or, whatever you named the script. 3. Of course, you can move the echo statement anywhere inside main script, as the variables will be available.
-
True, that is why the last line is in there.
-
You see this form? <form action="insert.php" method="post"> CLOSE IT. <form action="insert.php" method="post"> Target: <input type="text" name="Target" /> Comment: <input type="text" name="Comment" /> <input type="submit" /> </form>