I've managed to start a script that seems to read in the correct rows from the table I want. I didn't screw anything up which is a bonus.
Now some guidance (or if I should ask on another site because this is more general scripting advice I reckon more than VB specific)
I'm assuming everything I have selected is in memory. Should I write it to a file (if so how ?)
The next step is for me to add some formatting around the fields and combine them into one field.
So the end result would look like:
IngredientsFish
Chips
Vinegar
Cooking Time15 mins
etc
How should I do this ? Massage the formatting of each field and then combine them or do it at the same time ?
Once that is completed, it I will need to insert the new field into the post table where firstpostid = postid but I need to Add my new formatted and combined field at the start of pagetext making sure I don't overwrite what is in there.
Here's the script so far. If there are any serious issues with it please let me know. I really don't want to blow up my database, even if it a test copy.
PHP Code:
<?php
/**
* Here goes nothing
*
* Get the database connection details
*/
$user="";
$password="";
$database="";
$host="";
/*
* Connect to the database or die
*/
mysql_connect($host,$user,$password);
@mysql_select_db($database) or die( "Unable to select database");
/*
* Select all required fields rows in the 'thread' table that are not null
* That didn't work as all rows where selected even if the field was empty.
* Added AND recipe_ingrediants<>'' to the WHERE criteria
* Result but Remember to mistype 'ingrediants'
*/
$query="SELECT title, firstpostid, recipe_time, recipe_description, recipe_prep,
recipe_difficult, recipe_ingrediants, recipe_size, recipe_steps FROM thread
WHERE recipe_ingrediants IS NOT NULL AND recipe_ingrediants<>''";
$result = mysql_query($query);
/*
* Count and echo the number of rows just to make
* sure the amount of data returned looks about right.
*/
$num_rows = mysql_num_rows($result);
echo "$num_rows Rows\n </br>";
/*
* Print out the firstpostid and thread title just to prove that I got this right so far
*/
while($row = mysql_fetch_array($result))
{
echo $row['firstpostid'] . " " . $row['title'];
echo "<br />";
}
/*
* close the database connection because I need to work out what to do next.
*/
mysql_close();
?>