Php echo?

Status
Not open for further replies.
Lol!

Well, I might as well use this post now :D

Problem...

I am using an incredibly round about way of doing this so PLEASE bear with me.

I am using a form to extract poo from my database.... I have two options (actually I have a lot, but 2 will do for now...). HTML or TXT and headings on or off.

If the HTML box is checked, the data is outputted in table form.
If TXT.... tab delimnated text (i.e. no formatting). Headings, naturally, will print row 0 as headings.....

However, it doesn't work. I was going to do:

If html ticked then htmlheadings(); then htmlit();
else txtheadings(); and txtit()...

BUT I can't put 'use' the functions as when I put the below into the function it says not MYSQL - bugger off... (the headings bit works fine so I guess the problem is with mysql access)


Code:
e.g. htmlit():

$i=0;
while ($i < $num){
$field1=mysql_result($result,$i,"field1");
etc...

// output as html

EDIT - If that isn't clear (I'm not sober), I'll repost tomorrow...
 
Last edited:
I have 'connected' at the top....

Can't get the exact message now... but I assumed I could just:

Connect

if html ticked
....if headings ticked
.........display html headings
....display datahtml

if txt ticked
....if headings ticked
...........display txt headings
....display datatxt

But rather than have if this do if do if do if , I thought I'd split it into functions, where display data txt/html would be two functions (likewise for headings)
 
shine said:
If you move your sql into a function you will need to connect to the db inside the function.

:D

Makes sense I guess.


Will try it later...

incidently, does anyone know how to export a mysql database... as a csv, xls and sql file? (from within php - like phpmyadmin)
 
shine said:
If you move your sql into a function you will need to connect to the db inside the function.
Not true, but you do have to ensure the function 'knows' which MySQL connection you're referring to.

As for the export, if you want to do that 'natively' (i.e. not using mysqldump), you'll have to do it yourself.

I'd recommend a new thread when more sober tbh. This one is a mess. :)
 
Status
Not open for further replies.
Back
Top Bottom