Napoleon001
-
Posts
4 -
Joined
-
Last visited
Never
Posts posted by Napoleon001
-
-
Hi,
Is there a way for PHP to detect if a MySQL table column exists?
I know how to query a table and a particular column and if it doesn't exist it gives an error so if I had to do it a messy way I'll have to do that and just use the error suppression on that query but is there a proper way to do it?
If you want to read more details about my question:
It is because I have multiple sites linked together and some have multiple languages while others only have one. I keep the contents of each language in a column Contents_EN or Contents_FR.
I want the language selector to simply check what columns are available in this site table and display the options if any but I don't really want to do it the messy was as above and I don't really wan't to have a separate table with this info in it.
Any ideas/suggestions greatly appreciated!
Many thanks! [img src=\"style_emoticons/[#EMO_DIR#]/smile.gif\" style=\"vertical-align:middle\" emoid=\":smile:\" border=\"0\" alt=\"smile.gif\" /] -
On the second script, you're not actually doing anything with $name1 and $name2. All you are doing is passing the value sent from the form (i.e: nothing because $name1 and 2 have no value assigned to them in the 1st script so by default are blank).
In the 1st script, you need to actually put the names in the different <options> (hardcoded or even better by giving values to $name1 and $name2 and maybe getting the list from a database if you're feeling brave) and on the second script, using the same list that you used on script 1 have PHP get the name that was sent from the form and pick out the email address that it corresponds to.
Something like:
[code]
switch ($_REQUEST['recipient']) {
case "joe bloggs": $recipient = "joe.bloggs@hismail.com"; break;
case "jenny whoever": $recipient = "jenny.whoever@hermail.com"; break;
}
[/code]
[a href=\"http://www.tizag.com/phpT/switch.php\" target=\"_blank\"]This is a good site that I found and now use when my brain has a blank moment.[/a] It's easier that the PHP official website most of the time.
Hope that helps a bit. -
Hi,
You know how some websites have a page of text and somehow in various places they put related adverts in it?
A bit like this tiny example:
[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]This is a 1st paragraphe of text
SOME FANCY AND ANNOYING ADVERT THAT DISTRACTS YOU FROM ARTICLE
This is another paragraphe[/quote]
How do they do it?
Is there a better way of doing it than using "ereg_replace" like this? (wouldn't it be great if one could put PHP scripts into a DB)
[code]//I get my normal text from db
$textfromdb="<p>This is a 1st paragraphe of text</p><p>This is another paragraphe</p>";
// search for paragraphe break
$searchtext="</p><p>"; //could be a specially inserted tag
//get my advert from db
$some_advert = "<img src="image.gif">"; //This would also come from a db
//do search and replace
$bodytext = ereg_replace ($textfromdb, $searchtext, $some_advert);
//output result
echo $bodytext;[/code]
Any suggestions?
By the way, I'm not using it for putting annoying adverts into text, I hate that but its a good example that we're all subject to, so easy to visualise.
I have a need to put dynamic stuff in the contents that comes out of a DB (from 1 table cell) such as display 1 client testimonial randomly selected from a list or a randomly selected illustration picked from a selection, examples go on...
Any suggestions how to do this a better way? Maybe some techique or function that I've never heard of...
... much appreciated!
[SOLVED] PHP to detect if a MySQL table column exists
in MySQL Help
Posted
I think I need to read up about Describe a bit more. I familiar with it when querying MySQL in a Command Line but not with PHP script... what am I missing out on... [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /]