PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
<?php
//$query = "SELECT * FROM site_info WHERE pagename = '$filename'";
//$result = mysql_query($query);
//$row = mysql_fetch_row($result);
echo $row[5];
?>
//Some Random HTML Code
<?php
echo $row[7]; // Can I do this, or do I need to run the query again? It works, but is it standard and should work at all times? Or do variables clear after you close a PHP section?
?>
<?php
//$query = "SELECT * FROM site_info WHERE pagename = '$filename'";
//$result = mysql_query($query);
//$row = mysql_fetch_row($result);
echo $row[5];
?>
//Some Random HTML Code
<?php
echo $row[7]; // Can I do this, or do I need to run the query again? It works, but is it standard and should work at all times? Or do variables clear after you close a PHP section?
?>
It will work just fine unless you navigate to another page. That's the nice thing about php is you can jump in and out of code although you should try to keep some structure and keep it clean so it is easy to read. Your example though is typical of displaying a page with quite a few dynamic features. If you end up with mulitple queries though you are going to need to be more specific with your row names such as row_names, row_city blah blah
I did try it - that's how I knew it works if you read the original post.
I was just double checking to be sure it's proper to do so - I've been doing a lot of Flash coding lately that was working sometimes and wasn't working others - had a lot of trouble figuring out whether something was wrong with the Flash or the Javascript...there was a problem, yet on my computer it was working without any problem.
Just wanted to double check for PHP since I don't use it quite as often.
<?php
$this_var = 'doggiebones';
/*
The $this_var variable will stay unchanged until
A. You change it directly by setting it to another value
B. The script changes it for you using some type of logic
C. The script ends (it essentially evaporates)
*/
var_dump($this_var);
// Lets change it now
$this_var = 12;
var_dump($this_var);
// and one more time
$this_var = array('cat', 'dog', 'banana sandwich');
var_dump($this_var);
?>