xtopolis
-
Posts
1,422 -
Joined
Posts posted by xtopolis
-
-
The only way I could see you do this is place the contents of the file into a variable, and then replace their country line with the selected version of the line. Why aren't you using a database for this?
This is assuming the countries.php would just have a list like in your first post.
<?php $countries = file_get_contents(countries.php); //mysql select their country, comes out as "Canada" (str) $userCountry = "Canada"; $search = '<OPTION VALUE=\"' . $userCountry . '\">' . $userCountry . '</OPTION>'; $replace = '<OPTION VALUE=\"' . $userCountry . '\" SELECTED>' . $userCountry . '</OPTION>'; str_replace($search, $replace, $countries); //print list echo $countries; ?>
not tested.
-
looks like it should just be "\n" to replace not "\\n"
-
str_replace on the line endings? depending what type of endings they are you could probably str_replace("\\n", '', $textInput) \\n would be whatever line endings they are.
-
It works for me using your code. I had to refresh my cache though (CTRL F5 in firefox) to get it to show it.
-
-
You don't have to use a form at all if you're going to do it this way.
On your textfield, make a function that detects the enter key (you can google "javascript detect enter key". Then use whatever function you want to send the data via ajax... no form required.
-
echo "working"; set_login_sessions($username, $password);
if set_login_sessions() actually does anything with $_SESSION/ session_start() etc I would expect you to be getting an error for outputting "working" and then trying to set session headers.
-
What I'm saying is, in your loop right there, you're extracting the result set info, echoing html, and trying to plan columns all in the while loop.. That's a lot to do and manage for one loop. Break it down. You want each widget to go into a certain column, and in a certain order (likely the order they come out of the SQL statement).
This is what I'm thinking of. Tell me if it's off track:
<?php $columns = array(); while($row = mysql_fetch_array($sql)) { //check that widget exists if(file_exists('../incl/widgets/'.strtolower(str_replace(' ', '_', $row['name'])).'.php')) { //get column destination, place into array $col = $row['column'];//I am assuming this is an integer $columns['column' . $col][] = '../incl/widgets/' . strtolower(str_replace(' ', '_', $row['name'])) . '.php'; } } //build webpage layout, column 1 $col_1_width = '30%'; foreach($columns['column1'] as $widgy) { echo '<div style="float:left;width:'.$col_1_width.';">'."\n"; include($widgy); echo '<div style="clear:both;"></div>'."\n"; } //"close" that column ? echo '</div>'."\n"; echo '<div style="width:10px;float:left;"> </div>'; //main content? //build webpage layout column 2 $col_2_width = '68.5%'; foreach($columns['column2'] as $widgy) { }?>
Not tested..
-
Can also set it in php.ini
-
Explicitly set the timezone on your system.
"Please use the date.timezone setting, the TZ environment variable or the date_default_timezone_set() function."
-
Use a UNION. Also, your column "DATE" is a reserved word, consider changing it.
-
I may not be understanding, but doesn't your issue relate to this article: http://dev.mysql.com/tech-resources/articles/hierarchical-data.html ?
-
(What you have looks a bit complicated)
Can you approach the problem differently? Why not query your database and place the "widgets"
into an array of the available columns to get it all organized first, and then place the widgets? Perhaps a picture would help illustrate how you want it to be displayed?
-
Pass the id in the while loop, receive it in the javascript function.
<script type="text/javascript"> function show_confirm(mid) { var r=confirm("Really delete?"); if (r==true){ window.location = "deletemessage.php?ms=" + mid; } } </script>
(this above could be made more nifty with ajax)
... echo '<div id="delete"><a href ="#" onclick="show_confirm(\'" . $row['messageid'] . "\')" class="delete">X</a></div></div>';
Should be something similar to that. not tested.
-
-
Well, are you sending the email as the correct MIME type to support HTML? You didn't show any mail() code.
Otherwise, you should probably use your system appropriate version of "newline" which might be something like "\n" or "\r" or a combination... or neither?
-
I believe you can set this with php.ini (link)
I'm just not sure which thing to set ... I'm thinking it's include_path though
-
Ok, didn't see that part, sorry.
What is the content for the first file being required? There is probably something there holding up the script... I made myself a basic example with:
r1.php
<?php echo 'hi1'; ?>
r2.php
<?php echo 'hi2'; ?>
example.php
<?php $ar = array( array("desc"=>'desc1', "location"=>'r1'), array("desc"=>'desc2', "location"=>'r2'), ); ?> <table class="left_nav" cellspacing="0px" cellpadding="0"> <?php foreach($ar as $row) { echo "<tr>\n\t<td class='left_nav_header'>".$row['desc']."</td>\n</tr>\n"; //header echo "<tr class='left_nav_content_row'>\n\t<td class='left_nav_content'>"; $x = $row['location']; // gets block page location $incfile = $x . '.php'; // declares it as Blocks/location/file.php"; require($incfile); echo "</td>\n</tr>\n<tr>\n\t<td class='left_nav_footer'></td>\n</tr>\n"; //footer echo "<tr class= 'spacer'>\n\t<td> </td>\n</tr>"; echo "\n\n"; } ?> </table>
And it seemed to come out ok. So, let us see the content of the first (and maybe second) file being required..
-
I did a little googling, it seems they just encode it properly. Afaik, the raw headers are in the same format as a GET variable would be.
Saw this example: http://www.captain.at/howto-ajax-form-post-request.php (encodeURI)
Then saw these key aspects: http://xkr.us/articles/javascript/encode-compare/
(this shows a raw header example for an array value being posted: http://www.phpfreaks.com/forums/index.php/topic,226617.msg1045540.html#msg1045540)
-
Well, does the mysql query return more than 1 row?
-
$name = (int) $_POST['name'];
(though you should probably do validation on this rather than typecast it)
and maybe
$sqn="SELECT name FROM address WHERE id = $name";
-
Regarding recognizing and getting image dimensions, this script I wrote seemed to work on various images:
<?php $files = glob('./imgs/{*.gif,*.jpg,*.png}', GLOB_BRACE); $allowed_types = array( "gif" => 1, "jpeg" => 2, "png" => 3); echo '<pre>'; foreach($files as $f){ $type = exif_imagetype($f); if( !in_array( $type , $allowed_types ) ) { //trigger_error('Filetype not supported.', E_USER_ERROR); echo 'Unsupported' . "\n"; }else{ print_r(getimagesize($f)); } echo "\n"; } echo '</pre>'; ?>
Array ( [0] => 42 [1] => 44 [2] => 1 [3] => width="42" height="44" [bits] => 8 [channels] => 3 [mime] => image/gif ) Array ( [0] => 80 [1] => 80 [2] => 2 [3] => width="80" height="80" [bits] => 8 [channels] => 3 [mime] => image/jpeg ) Array ( [0] => 80 [1] => 80 [2] => 3 [3] => width="80" height="80" [bits] => 8 [mime] => image/png )
Your "imagecreatefrom____" section could be cleaned up a bit using a switch statement, the argument being the $type above.
-
edit
You're using GET , not POST to send the data. Change it to post, or change the line below to GET
you should sanitize your input!
$ecid = (int) $_POST['ecid'];
Isn't this last part backwards?
$query_EventListing = "SELECT * FROM tbl_events WHERE $ecid = tbl_events.eventCourseID" ;
instead:
$query_EventListing = "SELECT * FROM tbl_events WHERE tbl_events.eventCourseID = $ecid" ;
-
(googling this only led to premade scripts, and more focused towards appointment setting)
I am going to be storing persons' availability per day. The times will be broken up by hour, and it will have data for each of the 7 days of the week. I plan to use check boxes to allow the user to select which hours they are available. This schedule is just a general idea of availability per week, and will stay that way. I will also store their offset from GMT time since this will be international. Concept example:
(Person1)
Monday:
[x] 00:00->01:00
[ ] 01:00->02:00
...etc.
[ ] 22:00->23:00
[ ] 23:00->24:00
Tuesday:
[ ] 00:00->01:00
[ ] 01:00->02:00
...etc.
[x] 22:00->23:00
[ ] 23:00->24:00
etc.
Idea:
-I had originally planned to use a "binary" system to store which boxes were checked... 00:00->01:00 having a value of 1, 01:00->02:00 having a value of 2, store a value of "3" to represent that they had checked those boxes. This way, I could have a table with columns for each day of the week, storing an integer per column for a user; seems simple.
Concerns:
+I could later break down the times further, into half hour increments and have little effect on the table design (store a different integer)
-It seems like I'd have to convert from my "stored binary method" in PHP, and couldn't do easy selections in mysql? (for example, show all people available on Tuesday, 1pm-2pm) or (show the most popular hour per day [have to deal with timezone offset, and then conversion of stored number to hours available])
These sample queries are important to what I want to do.
Potential Inaccuracies:
I am not that good with binary. If I'm not mistaken, I have the right idea above, but could be storing more data using smaller numbers (or the same #s but representing more combos)? Please explain if I've confused myself while trying to use the concept so that I can use it more efficiently.
Specific Questions:
-Aside from what I mentioned above, I would mainly like input on a good database design to store the concept above. How would I store their hours of availability (especially if they are not consecutive) and have a design flexible enough to break down / combine the increments differently if needed?
-What functions would I use in PHP or MySQL to handle conversion of timezones if I store their data in the same format, but track their GMT offset? (This will go on a graph, localized to their time, showing the other users availability)
[Let me know if I've been unclear]
Thanks
[SOLVED] Loop through a <select> ?
in PHP Coding Help
Posted
This works, but you should use a database.