Jump to content

How to use Mysql(phpmyadmin) to print data title on page


ljzxtww

Recommended Posts

hi:

 

I want to create a URL into mysql data(phpmyadmin)

i want to put url into mysql data(phpmyadmin)

I want to print on page.

like title call  <?php bloginfo('name');  and this data is in phpmyadmin. and print name on php page call <title>PHP Freaks Forums </title>

how to print on page. and also other stuff. like I want to print URL, tilte, bbsurl

db_ceoemail

 

please help me

 

thank u

Larry

Link to comment
Share on other sites

Are you familiar with using SELECT from mysql to grab a row from your database, and then how to successfully output it? If not, I'd suggest reading some tutorials.

 

yes I got it work. but I wrong messenge:

 

Parse error: syntax error, unexpected '<' in C:\www\test\hearder.php on line 2

code is:

 

<?php

<title>echo $rows['db_names']</title>

?>

 

 

Link to comment
Share on other sites

<?php

echo "<title>$rows['db_names']</title>";

?>

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\www\hearder.php on line 2

 

problem again

Link to comment
Share on other sites

<?php

echo "<title>$rows['db_names']</title>";

?>

 

Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in C:\Program Files\www\hearder.php on line 2

 

problem again

 

 

You need to learn a few basics about outputting variables to the screen.

 

First off, when you are in between <?php and ?>, the only thing printed as html is that which is echo'd.

 

Secondly, You have to end any and every line with a semicolon. Example: echo "hello world!";

 

Thirdly, if you are using double quotes for your echo, using an array with a string as an index cannot be in a single quote. Example: echo "$row[variable]"; not echo "$row['variable']";

 

Fourthly, if you are using single quotes, the only way to display a variable is to temporarily end the quote, truncate the variables with periods(.'s) and then startthe quote again. Example: echo 'The value '.$variable.' has been set into a variable'; not echo 'The value $variable has been set into a variable';

 

So in summary. If you want some variable between title tags, you can do it a few different ways:

 

either: <?php echo "<title>$variable</title>"; ?>

 

or

 

<title><?php echo $variable; ?> </title>

 

and ther are other slight variations, but those are the main 2.

Link to comment
Share on other sites

<?php
    echo '<title>'.$rows['db_names'].'</title>';
?>

or

 

<?php
echo "<title>{$rows['db_names']}</title>";
?>

 

I believe the second one is right.... berate me and call me a fool if not..

 

Nate

 

I believe they are both correct. Putting a variable in between curly braces is as if you ended the quote, truncated with dots, and then continued the quote afterwards. so it's be equivalent to <?php echo "<title>".$rows['db_names']."</title>"; ?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.