| Index
» Projekty
» phpMyEdit
» Fórum
» Using Same Page for Many Tables! |
 |
Justin Baker
Založený: 10.04.2007
Príspevky: 13
Zaslal: 2007-04-10 12:32
Návrat hore
Odpovedať s citátom
|
I have experience in PHP coding but am very NEW to this PHPMYEDIT ... I think this is a great system once I learn it more in deep.
I am having troubles making a code work that has a drop down menu for selecting a particular table from a DATABASE.
The database will have many tables in it ALL with the same exact coloumn/data structure .. and they are fetched by this code i have written :
| Kód: |
$i = 0;
$sql = "SHOW TABLES FROM $database";
$Tables = mysql_query($sql);
echo ' <form action="' ,$_SERVER['PHP_SELF'], '" method="post">';
echo ' Select Table : <SELECT NAME="table_select">';
while ($i < mysql_num_rows ($Tables)) {
$tb_names[$i] = mysql_tablename ($Tables, $i);
echo '<OPTION VALUE=' .$tb_names[$i]. '>' .$tb_names[$i]. '</option>';
$i++;
}
echo ' </SELECT>
<input type="submit" name="table_submit" value="Submit" />
</form>';
|
that puts a DROP DOWN menu on top of the list.. when you select a specific table from the drop down menu... the PHPMYEDIT DOES indeed pull up the correct table and displays it PROPERLy under the drop down menu.. where it shows the list of the table contents and is ready to edit... so i know THAT WORKS!!!
but when i hit to ADD or CHANGE a field that it doesnt do anything but goes to blank page!
This is the code that I have that makes it select the right table from the database and turns the variable for the table name to the $opts['tb'].. thats how it knows to display the table seclected from the drop down menu.
| Kód: |
if (isset($_POST['table_submit']))
{
$dbTable = $_POST['table_select'];
echo '<B>Name of Table: ' . $dbTable. '</B>';
$opts['tb'] = $dbTable;
snip.... rest of stock phpmyedit code.....
}
|
So everything seems to work the way i want with the drop down table selector on top.. and having it show the correct table for editing.. but then i cant change or add anything to it!
Thank you in advance for the help!
Cheerz
Justin
|
michal
Založený: 17.06.2003
Príspevky: 537
Bydlisko: Slovakia
Zaslal: 2007-04-13 12:19
Návrat hore
Odpovedať s citátom
|
http://opensource.platon.sk/projects/doc.php/phpMyEdit/html/configuration.cgi-variables.html
is what you are missing (mainly persist variables for table).
(also use some addslashes function to table name fetched from cgi).
|
Justin Baker
Založený: 10.04.2007
Príspevky: 13
Zaslal: 2007-04-17 11:58
Návrat hore
Odpovedať s citátom
|
HI.. thanks for the reply... i did find this page after i posted the message. and i played with it some and still couldnt figure out how to get it to work, using my drop down code. What do i had for the prefix?! using table submit or table select from my drop down code?!
so i use persist?! i tried them all and cant get either one of them to work.. and where to place this code? yeah i am new to this phpmyedit! :) thank you for yoru time!
|
Justin Baker
Založený: 10.04.2007
Príspevky: 13
Zaslal: 2007-04-17 15:30
Návrat hore
Odpovedať s citátom
|
Thanx Michal :)
I got it to work. I didnt have the arry variables right before.. and then it was wrong spot as well.
here is what I added right after the drop down menu code and it made it work:
$opts['cgi']['persist'] = array ('table_select' => $dbTable);
and it worked!
Thanx doode Cheerz! :)
|
|
Odoslať novú tému
Odpovedať na tému
|
|
|
|