Page 3 of 3
Posted: Thu Sep 16, 2004 10:12 am
by paquin1
no problem, I'll be here, and thanks for your help

Posted: Thu Sep 16, 2004 10:16 am
by John Cartwright
dethron wrote:thanx now, give some time

just sit, and relax

You should encourage users to figure out the solution on their own.. not do it for them. :S... make it a better learning experience
Posted: Thu Sep 16, 2004 10:18 am
by dethron
by the way using int as a variable name, is not good

Posted: Thu Sep 16, 2004 10:19 am
by dethron
Phenom, be sure that, i will do that

just wait the next post

i do not have a IIS with PHP support, i'm just cheking the $$, is OK for IIS?
Posted: Thu Sep 16, 2004 10:22 am
by John Cartwright
It's nice to see someone new helping out as much as you
keep up the good work..
back to the topic..
Posted: Thu Sep 16, 2004 10:25 am
by dethron
thnx, i love this forum

and i'm a very old member of it

Posted: Thu Sep 16, 2004 10:26 am
by paquin1
I think you are right, and I don't expect other to do my work... yet I did what I need to get the job done, but it took lots of code. I'm hopping to learn how to code better by looking on how other do it.
on the IIS I don't think is working. because I still get errors..
Posted: Thu Sep 16, 2004 10:28 am
by paquin1
im getting an
Notice: Undefined variable: Select one in c:\inetpub\wwwroot\test.php on line 43 --- the line for $$
Posted: Thu Sep 16, 2004 10:38 am
by dethron
Now we are go
I cut the db connection part, and assigned the values manually. So you should have do some good work to practice.
I did a mistake by adding $pulldown to every member of $mess array. I fixed it now
Code: Select all
<?php
$arr[0]->file_id = 1; $arr[0]->fd = "2004-1-20";
$arr[1]->file_id = 2; $arr[1]->fd = "2004-5-10";
$arr[2]->file_id = 3; $arr[2]->fd = "2004-1-30";
$arr[3]->file_id = 4; $arr[3]->fd = "2004-10-13";
$pulldown = "<option selected>Select one</option>\n";
$mes = array(1=>'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');
for($i=0; $i<count($arr); $i++){
$date = $arr[$i]->fd;
if (ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
$$mes[$regs[2]] = $pulldown.$$mes[$regs[2]]."<option value = "download_file.php?uid={$rows['news_id']}">$regs[3]</option>\n";
} else {
echo "<br>Invalid date format: $date";
}
}
?>
Now you can use $jan, $feb, $mar as your variable.
Try it, if you get any error, then we can blame IIS with PHP

Posted: Thu Sep 16, 2004 10:40 am
by dethron
Try the code above alone, it should be work.
$rows['news_id'] should be replaced by $arr[$i]->news_id
Posted: Thu Sep 16, 2004 11:01 am
by paquin1
Ok it works, but with errors
Notice: Undefined variable: jan in c:\inetpub\wwwroot\test.php on line 43
Notice: Undefined variable: may in c:\inetpub\wwwroot\test.php on line 43
Notice: Undefined variable: oct in c:\inetpub\wwwroot\test.php on line 43
line 43 being the line 11 of last code...
and some how I don't know why but in my January pulldown menu I get double "Select one" and in my attempt with long code I did not get the first row from MySQL so it might be ISS that has some problems with this double "Select one" and missing the first row with my old long code.
can you tell me what the $$ means.. is this like saying grab $mes[$regs[2]] and make it all one new variable?
Posted: Thu Sep 16, 2004 11:08 am
by dethron
i think IIS(PHP) has some problems to use $$.
why don't you install phptriad buddle, it works great on Windows.
Let me explain $$:
I do not know the grab, but YES, it makse a new variable, and also power to reach variables without knowing its name
$one = "apple";
$apple = "cat";
echo $$one; // displays cat

Posted: Thu Sep 16, 2004 11:21 am
by paquin1
well i try $$one and it works fine... but thanks a lot for your help, I will fix the code you posted to work with MySQL and play arround to see if I can eliminate all this errors. Some how I had an idea of using the for loop, but was not sure how to do it. I'll try some more and post anything I come up with.
Thanks again for your help.
Posted: Thu Sep 16, 2004 11:29 am
by dethron
Your welcome, back again to forum soon
Good Lcuk.
Posted: Fri Sep 17, 2004 10:05 am
by paquin1
Ok, I finally got it to work. I try so many things but this is what worked for me. I took off an extra $$mes[$regs[2]] and change the for loop for a do..while loop because some how with any other loop I will not get the first row from MySQL.
New things I learned.

Creating new variables by adding an extra $ to the array or other variables... $$mes[$regs[2]]

learn to understand the array more by displaying what mysql rows had and by printing what was inside of the arrays.
Code: Select all
<?php
$query = "SELECT file_id, DATE_FORMAT(file_date, '%Y-%c-%e') AS fd FROM files";
$result = mysql_query($query);
$rows = mysql_fetch_array($result);
$pulldown = "<option selected>Select one</option>\n";
$mes = array(1=>'jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec');
do {
$date = $rows['fd'];
ereg ("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs);
$$mes[$regs[2]] = $pulldown."<option value = "download_file.php?uid={$rows['file_id']}">$regs[3]</option>\n";
}while ($rows = mysql_fetch_array($result))
?>
Code: Select all
// this is part of the code for the table
<tr align="center">
<td>January<br>
<select name="select" onChange="MM_jumpMenu('parent',this,0)"><?php echo $jan ?></select></td>
<td>February<br>
<select name="select" onChange="MM_jumpMenu('parent',this,0)"><?php echo $feb ?></select></td>
<td>March<br>
<select name="select" onChange="MM_jumpMenu('parent',this,0)"><?php echo $mar ?> </select></td>
</tr>