Psycho
Moderators-
Posts
12,157 -
Joined
-
Last visited
-
Days Won
129
Everything posted by Psycho
-
<?php . . . $message = stripslashes($message); mail("mysite@mysite.com","Form Submitted at your website",$message,"From: Contact Form"); mail($Email, "Thank You","Your message was received","From: mysite@mysite.com"); header("Refresh: 0;url=http://mysite.com/thanks.html"); . . . ?>
-
i am wanting the value to echo $gender in a drop down menu
Psycho replied to runnerjp's topic in PHP Coding Help
Well, you still didn't answer my questions above as to whether you have done some of that debugging. I would start from the beginning. First check the "default" values received from the query to make sure you are setting those values correctly. If they are check to see if they are being interpreted correctly in the comparison. If so, then determine what is wrong. If I run this code, the select list is getting set to the correct default value. <select name="month"> <?php $month = '3'; for($i = 1; $i <= 12; $i++) { $selected = ($month==$i)?' selected="selected"':''; echo ($i < 10) ? '<option value="0'.$i.'"'.$selected.'>0'.$i.'</option>' : '<option value="'.$i.'">'.$i.'</option>'; } ?> </select> So, your problem is most likely that $month is not getting set properly OR the value of $month has the zero padding on it. (e.g. '08' != '8') -
i am wanting the value to echo $gender in a drop down menu
Psycho replied to runnerjp's topic in PHP Coding Help
Again, don't just state that "it didn't work" give specifics of what IS happening. Is the select list being generated successfully? If so, have you checked the generated HTML output to see if "selected" is in the code, but maybe not formatted correctly? How are you setting the variable for the default value $month? Have you verified that it holds a value? Were not mind readers. Perhaps the $month value has the leading '0' in which case '08' != '8'. This is a very simple problem and should not need two pages on the forum to solve. -
i am wanting the value to echo $gender in a drop down menu
Psycho replied to runnerjp's topic in PHP Coding Help
Didn't realize you already had an IF statemetn in that code. But, it would be very helpful if you explained what was happening instead of just saying "It didn't work" <?php for($i = 1; $i <= 12; $i++) { $selected = ($month==$i)?' selected="selected"':''; echo "<option value=\"0$i\"$selected>0$i</option>"; } ?> -
You need to learn how to do JOINS in your queries. NEVER do looping queries - it is terribly inefficient and a resouorce hog. Also you will do yourself a great favor by using descriptive variable names. This "should" get what you want. I can't test it becuause I don't have your table structures, but the logic is sound. <?php //Only 1 query needed $query = "SELECT COUNT(*) as votecount, candidates.id as c_id, candidates.name as c_name, regions.id as r_id, regions.name as r_name FROM newvotes JOIN candidates ON newvotes.answerid = candidates.id JOIN regions ON newvotes.regionid = regions.id GROUP BY candidates.id, regions.id ORDER BY candidates.name"; //Run the query $result = mysql_query($query) or die(mysql_error()); //Display the results $current_candidate = ''; while ($record = mysql_fetch_assoc($result)) { if ($current_candidate!=$record['c_name']) { $current_candidate==$record['c_name']; echo "<b>$current_candidate (".$record['c_id'].")</b>\n"; } echo " --- Region: " . $record['r_name'] . "(".$record['r_id']."), "; echo "Count: " . $record['votecount'] . "<br>\n"; } ?>
-
i am wanting the value to echo $gender in a drop down menu
Psycho replied to runnerjp's topic in PHP Coding Help
Change $prevSelectedbirthmonth withthe default value you want. <?php for($i = 1; $i <= 12; $i++) { $selected = ($prevSelectedbirthmonth==$i)?' selected="selected"':''; echo ($i < 10) ? '<option value="0'.$i.'"'.$selected.'>0'.$i.'</option>' : '<option value="'.$i.'">'.$i.'</option>'; } ?> -
i am wanting the value to echo $gender in a drop down menu
Psycho replied to runnerjp's topic in PHP Coding Help
Hmm, I don't use printf much, this uses str_pad echo "<option value=\"{$optVal}\"{$selected}>" . str_pad($optVal, 2, '0', STR_PAD_LEFT) . "</option>"; -
i am wanting the value to echo $gender in a drop down menu
Psycho replied to runnerjp's topic in PHP Coding Help
<select id="day" class="input" name="DateOfBirth_Day"> <?php for ($optVal=1; $optVal<32; $optVal++) { $selected = ($day==$optVal)?' selected="selected"':''; echo "<option value=\"{$optVal}\"{$selected}>" . printf('%02s', $optVal) . "</option>"; } ?> </select> -
<?php if ($handle = opendir('/home/ectackle/public_html/uploader/uploaded_files/')) { while (false !== ($file = readdir($handle))) { if (preg_match('/\.jpg$/', $file)) { echo "<a href='$file' onclick='return hs.expand(this)' class='highslide'>\n"; echo "<img src='show_image.php?filename=$file&width=100&height=100' alt=''/>\n"; echo "</a>\n"; } } closedir($handle); } ?>
-
You were not being a jerk (and it was not my intention to be one either). I just wanted to emphasize that stating ALL of your requirements up front prevents a lot of rework and gets you a solution faster. It would ahve been just as much work for me to provide all of your requirements instead of having to go back and rework it.
-
From my experience adding that tot he actual field is not worth the time, effort or greater propensity of error. Just put the symbol right in front of the field Example: __________ Salary £ [__________]
-
Resize image and pad with set colour to fit standard shape
Psycho replied to dickiebow's topic in PHP Coding Help
Does that background color have to be part of the image? You could just put the image in a DIV with the color. I know it's not what you asked for, but just a thought. EDIT: This should be what you want: http://us.php.net/manual/en/function.imagecopymerge.php -
<?php case "250GSMAGL1": $Cover_package = "250 GSM Artboard Gloss Laminated 1 Side"; $Covpackage = 1.18; if ($quantity == 500) { $Covpackage2 = 70; } else if ($quantity == 1000) { $Covpackage2 = 130; } break; ?> Of course depending on your needs and requirements you could do something with arrays or functions. But, not enough information given to provide much else.
-
You should really be handling the user type withint he database instead of hard coding it like this. But here you go: function get_admin($user) { switch (strtoupper($user)) { case 'STEPPIO': $bgi = '1'; break; case 'FRANK': $bgi = '1'; break; case 'KARL': $bgi = '1'; break; case 'SAM': $bgi = '1'; break; case 'KRIS': $bgi = '1'; break; default: $bgi = '2'; } $_SESSION['admin'] = $bgi; return $_SESSION['admin']; }
-
I really like helping people out, but it irks me when someone gives requirements for a solution they need, then when provided a solution, they change the requirements. I don't meant to be a jerk, but it seems rude to me when someone does that. I'm sure that was not your intention, but it is always appreciated to get the full requirements up front instead of usign the forum for design. validName = /^[a-z0-9]+([\ ]?[a-z0-9])*$/i
-
Get rid of the first half of your page and change the second query to sort by featured instead of making it a WHERE requirement. FYI: Your IF/ELSE to determine the page needs some validation to ensure it is a number. ALWAYS validate user input whether it is coming from GET or POST. <?php function showdirectoryfree($category) { if(!isset($_GET['page'])){ $page = 1; } else { $page = $_GET['page']; } $max_results = 5; $from = (($page * $max_results) - $max_results); $query = "SELECT * FROM accounts WHERE category='$category' ORDER BY featured, companyname LIMIT $from, $max_results"; $result = mysql_query($query) or die (mysql_error()); while($row = mysql_fetch_array($result)) { echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\" class=\"bodyFont\">"; echo "<tr>"; echo "<td><b><span class=\"companyNameFont\">" . $row['companyname'] . "</span></b></td>"; echo "</tr>"; echo "<tr>"; echo "<td>" . $row['address'] . ", " . $row['postcode'] . "</td>"; echo "</tr>"; echo "<tr>"; echo "<td>Tel: <b>" . $row['telephone'] . "</b></td>"; echo "</tr>"; echo "<tr>"; echo "<td colspan=\"2\" bgcolor=\"#FFFFFF\"><a href=\"http://www.multimap.com/map/browse.cgi?client=public&search_result=&db=pc&lang=&keepicon=true&pc=". $row['postcode'] ."&advanced=&client=public&addr2=&quicksearch=" . $row['postcode'] . "&addr3=&addr1=\" target=\"blank\">Map/Directions</a> - <a href=\"/marketplace/sendemail/sendemail.php?emailto=" . $row['username'] . "\" onClick=\"return popup(this, 'notes')\">Send E-Mail</a></td>"; echo "</tr>"; echo "<tr>"; echo "<td align=\"left\"><hr width=\"100%\" size=\"1\" noshade=\"noshade\"/></td>"; echo "</tr>"; echo "</table>"; } $total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM accounts WHERE category='$category'"),0); $total_pages = ceil($total_results / $max_results); echo "<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" id=\"pagenumberBox\" class=\"bodyFont\">\n"; echo "<tr>\n"; echo "<td align=\"center\">\n"; if($page > 1){ $prev = ($page - 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev&category=$category\">Previous</a>\n"; } for($i = 1; $i <= $total_pages; $i++){ if(($page) == $i){ echo "$i \n"; } else { echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i&category=$category\">$i</a>\n"; } } if($page < $total_pages){ $next = ($page + 1); echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next&category=$category\">Next</a>\n"; } echo "</td>\n"; echo "</tr>\n"; echo "<tr><td align=\"center\"><a href=\"/marketplace/index.php\">Return to Marketplace</a></td></tr>\n"; echo "</table>\n"; } ?>
-
What IS the function showing? Is it shawing A time/date? Are you running this off a remote web server? If so, that server may very well be in a different time zone than you are. If you need the time to always be in YOUR time zone you will need to offset the current time accordingly. If you need the time to be in the USER'S time zone you would need to know that user's time zone in order to offset the time for each user.
-
Or shorthand <?php $value = ($_SESSION['sessionval']==true) ? true : false; ?>
-
Yes, they are doing the same thing. In the first example, the URL has specified the directory, but not the file, so the web server will attempt to load the "default" file in that directory based upon the default list. Usually something like: index.php, default.php, index.htm, etc. So the first one is actually referring to something like: index.php?state=logout The second example has identified the file (page.php) in addition to the parameters
-
You want to prevent 55% of all users from accessing your site? Interesting. You could use the $_SERVER['HTTP_USER_AGENT'] predefined variable to determine the browser.
-
Would you not want to trim the leading and trailing spaces off? Anyway, here is what you asked for: <html> <head> <script type="text/javascript"> function validate(inputStr) { var inputAry = inputStr.split('\,'); var outputAry = new Array(); validName = /^[a-z0-9]+[a-z0-9\ ]*[a-z0-9]+$/i for(var i=0; i<inputAry.length; i++) { if (validName.test(inputAry[i])) { outputAry[outputAry.length] = inputAry[i]; } } var outputStr = outputAry.join(','); return outputStr; } </script> </head> <body> Input:<br> <textarea id="input">player1, player2, player3,player4</textarea><br><br> Input:<br> <textarea id="output"></textarea><br><br> <button onclick="document.getElementById('output').value=validate(document.getElementById('input').value);">Test</button> </body> </html>
-
Or include all "sections" in one form and use DHTML to change from one section/slider to another. You can eitehr continue to do the validation via AJAx for each sectiona independently and/or do it within the JavaScript.
-
I don't see where $_SESSION['mls'] is used in that code at all (or any session values for that matter). So, how would you know the value has been altered when you don't even use it?
-
I have an email validation expression that works, but I want to see if there is a way to refine one part and/or add one additional check. Here is the expression: /^[\w\+-]+([\.]?[\w\+-])*@[a-zA-Z0-9]{2,}([\.-]?[a-zA-Z0-9]{2,})*\.[a-zA-Z]{2,4}$/ The BOLD blue section ensures the username consists of 1 or more valid characters (alpha, numeric, '_', '+', '-') The blue section allows the user to have zero or more sub elements (separated w/ a period) with the same valid characters The BOLD red section ensures the domail consists of 2 or more valid characters (alps, numeric) The red section allows the domain to have zero or more sub domains (separated w/ a period or '-') and the same valid characters [yes, the dash is not a sub-domain delimiter, but it is not acceptable at the begining or end of a domain just like the period] The BOLD green section ensures the TLD consists of 2 to 4 acceptable characters (alpha or numeric) So, my question are: 1) Can the blue sections be combined more efficiently into one such that the usrename can accept a period, but not at the beginning or end, and cannot appear in succession? 2) Can the red section be combined into one such that a period or dash cannot be at the beginning or end - and they cannot appear in succession of each other? 3) How can I add a minimum/maximum check to the entirety of the blue section and/or the (red + green sections)? I want to ensure the username is between 1-64 characters and the domain is between 5-255 characters. Currently for #3 I am using a second regex test as follows: /^(.{1,64})@(.{4,255})$/
-
It would be very helpful if you were specific in your questions. mgallforever, gave you a solution for your first question as posed, but then you changed the request. I then gave you a solution but you now say it does not meet your needs because of a requiremetn that you did not state. You state that you want to know "whick link" was clicked on that page. Does that mean there are multiple links on that page that go to the same palce? It would be helpful if you explained what you are trying to accomplish. One "possible" solution would be to not have those links go directly to the intended page. instead have them go to separate intermediary pages: Instead of: <a href="nextpage.php">Link 1</a> <a href="nextpage.php">Link 2</a> Use this: <a href="nextpage1.php">Link 1</a> <a href="nextpage1.php">Link 2</a> And then for those pages (nextpage1.php & nextpage2.php): include(nextpage.php) You could then add code on those pages to 1) verify they are coming from the appropriate page and 2) know which link they clicked.