i wanted to align my Welcome note to the right by using <p align="right">
but it doesnt seem to work..is it because Session/PHP doesnt work with p align?
<?php
session_start();
if($_SESSION['SESS_admin'] == 0)
require("do_menu.php");
else
require("do_menu3.php");
require("auth.php");
require("do_html_header.php");
do_html_header();
print"<p align=\"RIGHT\"><h1>Welcome ". $_SESSION['SESS_FIRST_NAME']."!</h1></p>";
do_menu();
?>
thanks in advance!
Try this
echo "<div style='text-align:right'><h1>Welcome ". $_SESSION['SESS_FIRST_NAME']."!</h1></div>";
It is probably because your <h1> tag is not set to align right and is instead set to align center. You need to override this with CSS. Try this instead: echo "<h1 style="text-align: right;">Welcome ".$_SESSION['SESS_FIRST_NAME']."</h1>"
print"<p align=\"RIGHT\"><h1>Welcome ". $_SESSION['SESS_FIRST_NAME']."!</h1></p>";
You're allowed to use single qoutes, too. It might help you here.
echo '<p align="right"><h1>Welcome '. $_SESSION['SESS_FIRST_NAME'] .'!</h1></p>';
Also, print should have a space after it, or you should be wrapping what's being printed in parenthesis.
Edit: I used echo out of habit, sorry. You can use either, but I [think] I read somewhere that echo is a better choice than print - not 100% sure, though, but they do the same thing. I'll go look it up, though. (Of course, if anyone reading this knows if one is better than the other, let me know!)
The use of ALIGN is deprecated, and fails in many situations. In your case, you're probably writing something in the html_header.php which causes ALIGN to fail.
Try doing:
print "<div style=\"float:right\"><p><h1>Welcome ". $_SESSION['SESS_FIRST_NAME']."!</h1></p></div>";
<div align =right>
<?php
..
..
.. // code you want to align to the right
..
?>
</div>
This way you can align a particular segment of code to the right.
If later you want to align some other segment of code in the center.
Then you can use
This way you can align the different segments differently.
Related
My problem is only changing session variable from default text color to another text color.
here's my code that doesn't work below. how to correct it to work well?
thank you :)
<div class="welcome-admin">
<h3>Welcome: <?php echo "<span style="color:green;">.$_SESSION['Fname'].</span>";?></h3>
</div>
the output is still the same as default color.
Your encapsulation is incorrect. You have to many double quotes.
<h3>Welcome: <?php echo "<span style="color:green;">.$_SESSION['Fname'].</span>";?></h3>
Better off doing something like this
<h3>Welcome: <span style="color:green;"><?php echo $_SESSION['Fname'];?></span></h3>
I am here once again with a problem. [:S]
Everything is stacking together!
Here's the code:
while ($row = mysql_fetch_array($data)) {
echo "<div id='blPost'>".
"<a href='read.php?pageid={$row['id']}'>".
"{$row['title']}</a> | Date: {$row['date']}".
"<div class='sep' />";
$sbstS = substr($row['data'],0,500);
echo $sbstS;
echo '</div>';
The problem is, everything is stacking together! If someone could help, here's my testing server. This is the development server I'm using. I've already fiddled with it a few times. This is a 1 day outdated version of the CMS. It uses the same functions and everything, but missing the images, such as the potatoes. Thanks.
its bunched because of the height attribute in the .sep class in your css
Your first blPost div is never closed.
<div class="sep" />
is not valid. You need to close your divs correctly.
You should to use
mysql_fetch_assoc($data)
for using
$row['id']
that syntax.
http://php.net/manual/en/function.mysql-fetch-assoc.php
Whenever I move the codeblock that generates courses with a grade of "F", it does not not echo out the courses that meets the criteria. But when I move it to beginning of the main div header of the script it displays well.. What could the problem be? I actually want it to be at the end of the script for the sake of printing out. I've also checked the source code and the parameters I was looking for wasn't there.
Pastebin of full code
echo "<table bgcolor = red >";
echo "<tr align= \"center\">";
$carry_over = array();
$score_count = mysql_numrows($query8);
echo "<th>"."Failed Courses : "."</th>";
if($score_count !== 0){
while ($row8 = mysql_fetch_assoc($query8)) {
echo"<td>". $row8['course_code']."</td>;
}
}
echo "</tr>\n";
echo "</table>";
There are inconsistencies between your provided example here and the pastebin code you linked to. Which version are you using?
If it's the pastebin version you may be having issues with this line:
echo "<th>"."Failed Courses";
You are missing the </th> tag which could be messing with your output.
It seems like it is going to be a long bit of code so I'm posting it here, I don't intend for this to be an answer to your problem as I can't get it to do what you're saying.
PHP allows for information to be set outside of the PHP tags, and when that happens it is treated as regular HTML.
E.G.
<?php
If(2==2){
?><b>HELLO!</b><?php
}
?>
And
<?php
if(2==2){
echo "<b>HELLO!</b>";
}
?>
Will both result in <b>HELLO!</b> to be output to the screen. This is useful for things that might require a lot of HTML in more than one block, as well as HTML that may require extensive style definitions or other places where double quotes will be needed, for example
<div id="list_row[$i]" class="something something2 something3"> would have to be escaped as
echo <div id=\"list_row[$i]\" class=\"something something2 something3\"> whereas it could just be put more or less intact in php using the above mentioned fact. Now, there would still need to be an echo statement for the $i portion, as I don't think PHP processes the text, but I've never tried it so I can't be sure.
As for your HTML,
<th> tags are meant to be a header, aka in the top part of a table. <td> are meant to be table-data cells.
Seems like you're making a lot of unnecessary calls to the same MySQL tables, and I'm hoping I can condense it down a bit.
Why are you doing this?
echo "<th>"."Failed Courses : "."</th>";
do
echo "<th>"."Failed Courses : </th>";
and also before you do a while loop try to see what your results looks like.
$row8 = mysql_fetch_assoc($query8)
then print_r($row8);
post your results.
Also the table structure should be
<table>
<th></th>
<tr>
<td></td>
</tr>
</table>
I'm trying to make a header image change randomly based on a random number being chosen. This is the code I have right now, and it requires the entire tag.
<img src="http://www.example.com/site_gfx/headers/header_<?php echo(rand(1,7)); ?>.png" width="980" height="230" alt="Example Site" />
Is there any reason it would be dying like it is? Where the <?php echo part is is the PHP code i'm using to generate the random number, and I'd like to include that into the string for the img src
How's it dying? I'd try print or echo without parentheses, as I haven't seen echo() used before:
print():
<?php print(rand(1,7)); ?>
echo:
<?php echo rand(1,7); ?>
Figured it out. The problem is I didn't realize the <?php area was running within an echo command (stupid little oversight on my part). But modifying the echo statement that I was working with fixed it.
Thanks for the pointers, everyone.
Any reason you want to do this with PHP, it would probably be easier with javascript. try to remove the rand(1,7) from the bracket so as to have:
echo rand(1,7)
This would be a better approach to doing this
<?php
$number = rand(1,7);
echo '<img src="http://www.example.com/site_gfx/headers/header_' . $number . 'png" width="980" height="230" alt="Example Site" />'
?>
There may be an issue with using the <?php tag inside of another tag.
I barely know how to use PHP and I can't seem to make my code show an image if a condition proves true. This is the code:
<?php
$search=get_search_query();
$first=$search[0];
if ($first=="#"){
}
?>
I tried writing this thinking it would work and it didn't:
echo "<html>";
echo "<img src='http://chusmix.com/Imagenes/grupos/lujan.jpg'>";
Also I tried a code I found which started with the function: header() but it caused a tremendously long error, which said something like header already defined.
Thanks
You have used 'double quotes' incorrectly in the echo statement.
Try the following:
echo "<img src='http://chusmix.com/Imagenes/grupos/lujan.jpg' alt='Preview not available' />"
Regards,
Mahendra Liya.
You should var_dump($first) to know what it contains
check if the condition is really getting true
and also put single quote inside the double quote.
if ($first=="#"){
echo 'yes it is true';
echo "<img src='http://chusmix.com/Imagenes/grupos/lujan.jpg'>";
}
close the img tag
The part of the query string starting with # (so-called "hash") is not being sent to the server. That is, if your page is called like myblog.com/foo?bar=baz#quux, you php script will only receive myblog.com/foo?bar=baz. You need javascript if you want to handle urls with hashes.