Can this be done? (html + database)
Discussion
I've got a database that contains prices for a wesbite, the prices are displayed on the page via some javascript (we paste a line of JS on the page for the pricing & stock info). The price renders OK in the browser but if you view source code the price is not there, just the JS that then gives the price (makes sense). What I'm now looking at doing is implementing schema org data by way of meta tags. What I'd like to know is can this be done via the existing database? ie, can I just add a line of code to the html pages like <meta itemprop="price" content="£10.00"> where the £10.00 part would be pulled from the DB?? (so there would be soemthing like <?php echo $price; ?> in the inverted commas of the content=)
??
or is it time to start again??
TIA
??
or is it time to start again??
TIA
WinstonWolf said:
Dave_ST220 said:
The problem I have is all pages are html rather than php. I guess I could look at changing all pages then using an htaccess rule to cover the change from html to php extensions??
Not really, the PHP runs on the server then dishes up the HTML.You'd be better off doing it 'correctly'.
A basic db driven PHP site isn't much more difficult to build than an HTML one.
cornet said:
When you say "a database" what do you mean ?
I'l guessing this isn't a database in the normal sense of the word (MySQL for example) but maybe a json/csv file containing all the prices
Also I'm not sure what the problem is you're trying to solve, is it for google shopping search or similar - depending on what the problem is there might be other ways to solve this rather than PHP
It's a MySQL database.I'l guessing this isn't a database in the normal sense of the word (MySQL for example) but maybe a json/csv file containing all the prices
Also I'm not sure what the problem is you're trying to solve, is it for google shopping search or similar - depending on what the problem is there might be other ways to solve this rather than PHP
It isn't no, which I guess explains that! Quick read reveals this can be done in htaccess, is that the best & only method? Or can some code be added to the actual HTML pages in question? Thanks for your help so far!!! It's a great help
ETA, all I get in the source when it's added is exactly what I added! It doesn't show on the page in the browser, just in the source.
ETA, all I get in the source when it's added is exactly what I added! It doesn't show on the page in the browser, just in the source.
Edited by Dave_ST220 on Thursday 24th April 09:11
Tried the htaccess rule & that didn't work either. Sitting here thinking about it I'm guessing I need more code to tell it to actually look at the DB? On one of the pages that IS PHP I can see code like this :-
$sql = "SELECT id, name, menulinktext FROM categories WHERE id=".mysql_real_escape_string($_GET['id']);
$result = mysql_query($sql);
Shame, I thought it would have been simple but should have known better! All the info is sat there in a DB, I thought I could "tap" into it to provide this extra meta info
$sql = "SELECT id, name, menulinktext FROM categories WHERE id=".mysql_real_escape_string($_GET['id']);
$result = mysql_query($sql);
Shame, I thought it would have been simple but should have known better! All the info is sat there in a DB, I thought I could "tap" into it to provide this extra meta info
Arh, this is falling into place. I can't just query the DB for "price" as there are loads of prices. I need to query it for the product ID too so the two match up. If I've got it all correct in my head it will be easier to hard code each darn page with this info anyway As I said currently we paste JS to each page which then renders all the info in the browser but not to bots. (& looking at the JS all that does is pull the info from the DB via another file named data). Sadly it doesn't look possible. Thanks for taking the time anyway
bishbash said:
Decent bots will use something similar to http://phantomjs.org/ to be able to 'read' the javascript parts of the page if that's what you're worrying about?
That is all I'm worrying about! To recap, we paste some JS to the page. The page then displays the prices in a browser. View source you just see the JS. I need the bot to see the price along with the schema.org tags.Thanks, I think I really need to start again. I've just used a few tools to view the pages as various bots. None of the prices or anything are there. If I compare to competitors all the info is there. Obviously bots will love them more than me The weird thing is I know 100% Google was showing this info in the SERP's last year, like they WERE reading the JS & using it. maybe they decided this schema.org lark was the way to go?? Anyway, thanks for all of your time people, some decisions to be made!!
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff