sxyloverboy 0 Report post Posted May 17, 2006 Hey i have a little problem with my php script. i dont really know how to make it work ^^; I want to have this exact table: [link] ' I made mysql table that has one column for id(auto-increment, primary key), and then it has row and collumn and text. row means which row in the html table and collumn wich collum. (obviously ) here is the mysql table screenshoted from phpMyAdmin: r means row and c collumn anyways somehow i want to load all those datas into the html table....how do i do this? lol. i tried a few things with a while funciton and some things but my browser always crashed when i opened the page....^^; and now you might be asking why do i want to do all this if i can just have a html table? well the answere is that i want to be able to edit the table better. so if you can also tell me how to do this next thing it would be great. i want to have that table but each table cell should have a text area of a form. and then it loads the info from mysql into it and then you can press save if you changed it and then it updates all of the mysql things. the important thing here is that it loads the data that it already has or when it updates all the fields it would just insert blank stuff except where you changed it yourself. i hope you can all understand this and help me with my problem Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted May 17, 2006 Looks to me like you should be looking for a Calendar or Scheduling script which shoud have an Admin section to add/modify/delete entries by date and time. There are already plenty of them available that are written for using with php and mysql. Why re-invent the wheel?Try Hotscripts and the SourceForge sites. Share this post Link to post Share on other sites
sxyloverboy 0 Report post Posted May 17, 2006 Ingenius. Thanks a lot ill look for a claneder thing. Never thought about that. But now for the actual learning effect. How would be a simple way to do this. Well a bit simple anyways. theres nothing simple about php im sure all the prefeabricated calender scripts are highly sophisticated and impossible to learn from if you want to learn how to do somehting. Share this post Link to post Share on other sites
jlhaslip 4 Report post Posted May 17, 2006 A set of nested loops would do it.Look under the php script sub-forum and check out previously posted scripts. I think there have been a couple written for ittsami. Use a SELECT to pull the information sorted by row and column. Use the outer loop to fill the row and the Inner loop to fill each column in that row. An IF statement in the script to check if the cell is empty, etc. Shouldn't be too hard. Share this post Link to post Share on other sites
elrohir 0 Report post Posted May 17, 2006 Like what you say about the learning effect I think I understand what you are looking for, have a little try with mysql_fetch_array(), you just have to structure things a little... good explanation at tizag.com. Hope that's what you're looking for Share this post Link to post Share on other sites
sxyloverboy 0 Report post Posted May 21, 2006 hm yeah i tried witht hat but it dosent seem to work >< Share this post Link to post Share on other sites
elrohir 0 Report post Posted May 22, 2006 can you get data out of your database normally, as in SELECT and all that stuff? Share this post Link to post Share on other sites
sxyloverboy 0 Report post Posted May 22, 2006 lol yeah. Share this post Link to post Share on other sites
elrohir 0 Report post Posted May 22, 2006 srry, srry, just checking... seems rather strange... do you get an error meassage or just no data? Share this post Link to post Share on other sites
sxyloverboy 0 Report post Posted May 22, 2006 well i mean i can do it its just that i cant get the table to be like i want it. it always makes it a bit stupid. - Share this post Link to post Share on other sites
elrohir 0 Report post Posted May 22, 2006 you are making a calendar right?so if you make a row per month and a table for every year, and make the HTML table just wide enough to get seven days, all you need to do is make the table so that you have ID in one col year in another, month in another, date in a fourth and events in the last.Then the php script should be simple enough - so long as you define width before looping, you should be fine. If you have the variables stored in the URL as GET strings, you can have different years, months and days. <?php//script for one month extraction// Connect to MySQL$table = $_GET['year'];$month = $_GET['month'];echo '<p align="center"> \n '.ucfirst($month).'$nbsp'.$table.'</p> \n \n';echo '<table width="whateverwidthyouneed" border="1"> \n ';echo '<tr> \n ';$result = mysql_query("SELECT * FROM $table WHERE month = $month") or die(mysql_error());while($row = mysql_fetch_array( $result )) { echo '<td> \n'; echo '<table> \n '; echo '<tr> \n '; echo '</td> \n '; echo $row['date'].' \n '; echo '</td> \n '; echo '</tr> \n '; echo '<tr> \n '; echo '<td> \n '; echo $row['event'].' \n '; echo '</td> \n'; echo '</tr> \n '; echo '</table> \n '; echo '</td> \n';}?> That should do it for the 'month' part....The only thing is that the page has to be wide enough so that even in 800*600 screen resolution, people can have seven boxes in a row.Hope that helped Good luck! Share this post Link to post Share on other sites