
marcelobm
Members-
Posts
57 -
Joined
-
Last visited
Everything posted by marcelobm
-
The session_start() function allows you to store some information in the $_SESSION global so you can access it from another file without having to send the parameter in the query string or via post. Regular variables that you declare inside your script are available trough that script only. For example, lets say that this file is called example.php <?php $a = 10; $b = 20; ?> The variables $a and $b will be available for the time the script is running, after that you cannot access them from another file, only if you do <?php session_start(); $_SESSION['a'] = 10; $_SESSION['b'] = 20; ?> if that is example.php then lets say you have another file example1.php, you could <?php session_start(); echo $_SESSION['a']; echo $_SESSION['b']; ?> Just remember that session variables are design to store small amount of information
-
need help putting an if statment in my loop
marcelobm replied to ricky spires's topic in PHP Coding Help
the error was in the foreach declaration and in the conditional -
need help putting an if statment in my loop
marcelobm replied to ricky spires's topic in PHP Coding Help
<?php foreach($topNav as $topNavs){ if ($pageName == $topNavs->title){ echo '<li><a href="'.$topNavs->title.'" id="'.$topNavs->title.'">'.$topNavs->title.'</a></li>'; }else{ echo '<li><a href="'.$topNavs->title.'" id="'.$topNavs->title.'" class="selected">'.$topNavs->title.'</a></li>'; } }?> -
need help putting an if statment in my loop
marcelobm replied to ricky spires's topic in PHP Coding Help
<li><a <?php echo ($pageName == $topNavs->title ? 'class="selected"' : '')?> href="<?php echo $topNavs->title; ?>.php" id="<?php echo $topNavs->title; ?>"><?php echo $topNavs->title; ?></a></li> -
Need help with dropdown menu displaying results from mysql please
marcelobm replied to PHP Learner's topic in PHP Coding Help
one of the things I can tell right away and I don't know i you are aware is that you are missing the closure tag for the option element </option> -
You can do echo $row; at the end of each cycle while ( $obj = mysql_fetch_array ( $rs_return, MYSQL_ASSOC ) ) { $row = "<h1>"; $row .= $obj ['title']; $row .= "</h1><div id=\"wrapper\"><div id=\"text\"><h4>Posted:"; $row .= $obj ['author']."By:".$obj['date']."</h4><p class=\"p3\"><span><img class=\"alignright\" src=\"".$obj ['imageUrl']."\"></img>"; $row .= $obj ['text']; $row .= "</span></p>"; echo $row; }
-
as far as I know, yes.
-
Need help with dropdown menu displaying results from mysql please
marcelobm replied to PHP Learner's topic in PHP Coding Help
As far as i can tell those are right approaches, i would recommend you do some debugging printing out the variable values to be sure that they have one. -
Ok, First in PHP you concatenate a string with a dot(.) not a plus(+), Second if you are concatenating a string with variables you don't use the echo in the middle. This is an example how you could do it: $link = mysql_connect ( 'localhost', 'root', '' ); if (! $link) { die ( 'Could not connect: ' . mysql_error () ); } mysql_select_db ( "php" ); $rs = "SELECT `id`, `title`, `author`, `date`, `imageUrl`, `text` FROM `items` "; $rs_return = mysql_query ( $rs ) or trigger_error ( $rs . ' has encountered an error: <br />' . mysql_error () ); while ( $obj = mysql_fetch_array ( $rs_return, MYSQL_ASSOC ) ) { $row = "<h1>"; $row .= $obj ['title']; $row .= "</h1><div id=\"wrapper\"><div id=\"text\"><h4>Posted:"; $row .= $obj ['author']."By:".$obj['date']."</h4><p class=\"p3\"><span><img class=\"alignright\" src=\"".$obj ['imageUrl']."\"></img>"; $row .= $obj ['text']; $row .= "</span></p>"; } also you have to remember to escape "
-
array_splice doesn't keep the associative index, you must do the operation manually $position_to_insert = 1 $capitals = array_slice($capitals,0,$position_to_insert,true) + $france + array_slice($capitals, $position_to_insert, null, true); You can also turn that into a function to be reusable.
-
glad i could help
-
you can just use a left or right join with full reference to the tables like: SELECT * FROM db1.table1 LEFT JOIN db2.table2 ON db1.table1.id = db2.table2.id WHERE db2.table2.id != ''; This should give you the records of db1.table1 that aren't on db2.table2
-
I just tried your code and works fine, make sure that you are making the request passing the case=progressbar parameter or you'll get an error
-
this script will create an image from 5 different sources. // Create image instances $src = imagecreatefromjpeg('images/desert.jpg'); $src1 = imagecreatefromjpeg('images/koala.jpg'); $src2 = imagecreatefromjpeg('images/lighthouse.jpg'); $src3 = imagecreatefromjpeg('images/Penguins.jpg'); $src4 = imagecreatefromjpeg('images/jellyfish.jpg'); $dest = imagecreatetruecolor(500, 100); // Copy imagecopy($dest, $src, 0, 0, 500, 500, 100, 100); imagecopy($dest, $src1, 100, 0, 500, 500, 100, 100); imagecopy($dest, $src2, 200, 0, 500, 500, 100, 100); imagecopy($dest, $src3, 300, 0, 500, 500, 100, 100); imagecopy($dest, $src4, 400, 0, 500, 500, 100, 100); // Output and free from memory header('Content-Type: image/jpg'); imagejpeg($dest); imagedestroy($dest); imagedestroy($src); imagedestroy($src1); imagedestroy($src2); imagedestroy($src3); imagedestroy($src4);
-
A good place to start is to change the content to contain standard characters and see if it pass the validation.
-
For each different category, no matter how different is the form you will have some common fields between them, so what I would do is, after I choose the category I want, I made a request to the file that generates the forms in which I'll put a switch statement that will give me the right fields for the category selected, as for the php handling of the submitted data, is about the same a switch statement that handles the data as required.
-
you could do something like: echo "<option value='$var2[DID]_$var2[directory]'>$var2[directory]</option>"; and then in the script that receives the value use $value_arr = explode("_",$value); and that will give you: $value_arr[0] = id; $value_arr[1] = path or directory]; That is the simple solution, the other solution is, when you get the id in the script that process the form, do a query with the id you get to retrieve the directory
-
You should use a select statement like this: [pre]$sql = mysql_query("SELECT * FROM news ORDER BY id DESC");[/pre] This way you'll get all the news in descending order.