Forum Moderators: coopster

Message Too Old, No Replies

PHP + metadata + variables

adding custom metadata

         

Stripeman

8:50 am on Jan 4, 2005 (gmt 0)

10+ Year Member



I am building a custom CMS solution with PHP and mysql.

I really have myh work cut out for me because my customer does not want to spend the $$ on a comercial solution.. dont even get me started!

The problem i am havin is that that I am trying to add custom metadata to the page. IE:

<meta name="if.classification" content="unclassfied">
<meta name="if.postdata" content="01232004">

I have like 35 of these.

I am using a form for the user to place the appropirate information in a mysql database.

The problem is how do i call these values from the database? How do i define these values andplace them into the content="" area?
like this:
<meta name="if.classification" content="$if.classification">

I tried this once.. but it makes it literal.

I will take any help i can get ... but I am not that seasoned ... so I ask you to please be descriptive...

Thanks much for any help...

Terry

Salsa

10:53 am on Jan 4, 2005 (gmt 0)

10+ Year Member



Stripeman, Welcome to WebmasterWorld!

The context of your code isn't clear to me, but if the code you posted isn't within PHP tags, you'll need to open and close the tags before and after a variable, like:

<meta name="if.classification" content="<?php echo $if?>.classification">

...here I'm assuming your variable is

$if
because dots are not valid variable characters. Maybe you mean to be concatenating two variables, like
$if.$classification
, or
classification
is a defined constant, but I'm not sure.

I hope this helps.

Stripeman

11:18 am on Jan 4, 2005 (gmt 0)

10+ Year Member



I GOT IT TO WORK!

yes.. what u are saying and what i did are very close...

here is the code for anyone else who may want it:

<?

mysql_select_db("$myDB") or die("Couldn't open the $myDB database");

$query = "SELECT id, classification, requester, author, be_number, country_codes, start_date, site_name, country
FROM db.db_main WHERE id = '$aid'";

$query_result = @mysql_query($query) or die (mysql_error());
$row = @mysql_fetch_array ($query_result);
// $row = @mysql_fetch_array

echo "
<META NAME=\"IL.title\" CONTENT=\"$row[target_name]\">
<META NAME=\"IL.poc\" CONTENT=\"$row[author]\">
<META NAME=\"IL.keyword\" CONTENT=\"$row[keywords]\">
<META NAME=\"IL.secur.classif\" CONTENT=\"$row[classification]\">
<META NAME=\"IL.secur.ctrl\" CONTENT=\"$row[ctrl]\">
<META NAME=\"IL.secur.relto\" CONTENT=\"$row[relto]\">
<META NAME=\"IL.secur.dissem\" CONTENT=\"$row[dissem]\">
<META NAME=\"IL.secur.declasson\" CONTENT=\"$row[declasson]\">
<META NAME=\"IL.cutdate\" CONTENT=\"$row[cutdate]\">
<META NAME=\"IL.postdate\" CONTENT=\"$row[start_date]\">
<META NAME=\"IL.summary\" CONTENT=\"$row[summary]\">
<title> $row[site_name] </title>
</head>";
?>

Stripeman

11:18 am on Jan 4, 2005 (gmt 0)

10+ Year Member



Yikes.. thanks very much for your reply though!

I really like these forums! I will help as many as I can ...