Extracting Info from HTML and storing in variables
Posted: Wed Aug 31, 2005 3:49 pm
Hi guys,
I have taken on a job of adding some features to an already existing website. The website in question shows content pages by content.php?pid=xxx (with xxx being the page id number). This then uses GET to pull all the page info, such as title, content, footer, etc, from a MySQL Database, using the pid to select the correct row in the table.
My problem lies here:
The owner adds car details in the content field by writing out the HTML for each entry each time, which he has to paste from a local file. So, this is too time consuming and he has asked me to make a page for him to add cars to these pages using input boxes for each single entry, so he doesnt have to mess with the HTML anymore. He also edits/removes the cars, which is where my main problem lies.
So, to explain better, each content field for each page (row in the sql table) now consists of something like this:
So, adding a cars details to this wouldnt prove so hard, as i could build a big string adding the html as i go, but viewing/editting the details would prove a problem.
I would need it to look at a full content field (which would look like the above), and then show me each detail in seperate boxes (also seperate variables).
So I'm thinking I would need some sort of code to select everything between the <'s and the >'s and the brackets themselves, and delete them, and as it deletes each one, add whats before it to a variable.
I hope you understand what I mean and have some ideas for me.
Thanks alot.
I have taken on a job of adding some features to an already existing website. The website in question shows content pages by content.php?pid=xxx (with xxx being the page id number). This then uses GET to pull all the page info, such as title, content, footer, etc, from a MySQL Database, using the pid to select the correct row in the table.
My problem lies here:
The owner adds car details in the content field by writing out the HTML for each entry each time, which he has to paste from a local file. So, this is too time consuming and he has asked me to make a page for him to add cars to these pages using input boxes for each single entry, so he doesnt have to mess with the HTML anymore. He also edits/removes the cars, which is where my main problem lies.
So, to explain better, each content field for each page (row in the sql table) now consists of something like this:
Code: Select all
'<b><u>Fiat Seicento SX</b></u><br>
<a href="http://www.yourdomain.co.uk/images/cars/IMAG0028.jpg"><img src="http://www.yourdomain.co.uk/images/cars/IMAG0028.jpg" width="300 height="300"></a><br>
<sup>Click to enlarge</sup><br>
<b>Year:</b> N/A<br>
<b>Reg:</b> S<br>
<b>Details:</b><br>
899cc<br>
3 door<br>
27k miles<br>
Sunroof<br>
Metallic paintwork<br>
<br>
<b>Price: £1,995</b><br>
<br>
<br>
<b><u>Fiat Punto S 1.2</b></u><br>
<a href="http://www.yourdomain.co.uk/images/cars/24IMAG0006.jpg"><img src="http://www.yourdomain.co.uk/images/cars/24IMAG0006.jpg" width="300" height="225" border="0"></a><br>
<sup>Click to enlarge</sup><br>
<b>Year:</b> N/A<br>
<b>Reg:</b> R<br>
<b>Details:</b><br>
5 Door<br>
CD Player<br>
Sunroof<br>
<br>
<b>Price: £1,495</b>I would need it to look at a full content field (which would look like the above), and then show me each detail in seperate boxes (also seperate variables).
So I'm thinking I would need some sort of code to select everything between the <'s and the >'s and the brackets themselves, and delete them, and as it deletes each one, add whats before it to a variable.
I hope you understand what I mean and have some ideas for me.
Thanks alot.