PHP - Moved: I Need Some Help With Building Mysql Driven Website With Php
This topic has been moved to Application Design.
http://www.phpfreaks.com/forums/index.php?topic=351877.0 Similar Tutorials Hey guys, I'm currently trying to make a tutorial website, and I'd like to have a fairly simple blog / news page that I can update with pictures and news stories. I would also like people to be able to comment on these postings. I'm pretty new to PHP but i made a simple blog using a php handler and a database table, but I was just wondering is there some 3rd party application I can use to manage my website with like users and articles and such without having to use their website layout? Like, programs such as WordPress and PHP-Fusion, Joomla etc, dont let you use your own html and css pages do they? I want to keep my website but have something purely in the background for me to manage the content and maybe like paste some script to my actual pages or whatever. Im just lost is all I need a little guidance =] Thanks a bunch. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=352102.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=348849.0 I have a table in my db with all my menus and submenues of my site, I'd like to show them in some kind of menu containing all of them each entry in db has the columns ID,NAME,TEXT,LEVEL,DEPENDENT level has a value of 1 or 2 depending if it's an item or a subitem dependent has a reference to the id of the section it belongs to Using dreamweaver I created two recordsets based on the level, they are called row_sections (only where level = 1) and row_subsections (only where level = 2) here is the code I tried to use: <?php do { ?> <p><a href="test.php?sec=<?php echo $row_sections['id'];?>"><?php echo $row_sections['name']; ?></a></p> //prints the section text <?php do { ?> <?php if($row_subsections['dependent'] == $row_sections['id']) { echo $row_subsections['name']."<br>"; //tries to print all subitems corresponding to the actual item } ?> <?php } while ($row_subsections = mysql_fetch_assoc($subsections)); ?> <?php } while ($row_sections = mysql_fetch_assoc($sections)); ?> Here's the output: Quote section 1 title subsection 1 subsection 2 section 2 title both section 1 and 2 should have two different subitems.. where is the problem? if I add the line <?php echo $row_sections['id']; ?> right before the second <?php do{ ?> it shows the corresponding ID for BOTH sections so I can't understand the problem... hello, I am trying to create a form that will log items. Say I have a list of fruits and I want to log the fruit and its color. I don't know how many fruits I have so I need the form to start with one row first then add rows after I hit enter. I then need to insert the fruits into mysql any ideas or links? anyone? I'm a newbie and want to explore on the use of php.I want to create a transcript system but do not know how to go about it.please where should i start from? Hi, I have this script which I would like to use to build an html form from a MySQL table. The <input text................ writes successfully to file but none of the other form types are written to file when using the elseif command Also, I would like this script to carry out the file write foreach row in the table It seems complicated and i am not sure if I am going about it in the right way, but here goes Code: [Select] //// Create Forms from MySQL $result = mysql_query("SELECT * FROM forms"); while($row = mysql_fetch_assoc($result)){ $field_label = $row['field_label']; $column_name = $row['column_name']; $field_type = $row['field_type']; if ($row['field_type'] = 'Text') { $stringData = "$field_label<input type=text name=$column_name>\n"; fwrite($fh, $stringData); } elseif ($row['field_type'] = 'Text Area') { $stringData = "$field_label<input type=textarea name=$column_name></textarea>\n"; fwrite($fh, $stringData); } elseif ($row['field_type'] = 'Select Menu') { $stringData = "$field_label<select name=$column_name></select>\n"; fwrite($fh, $stringData); } elseif ($row['field_type'] = 'Checkbox') { $stringData = "$field_label<input type=checkbox name=$column_name></textarea>\n"; fwrite($fh, $stringData); } fclose($fh); As always, any help is much appreciated I currently have an HTML form where the options for a certain drop-down menu are hard-coded. Instead, I want to use PHP to... 1. Look up the values in a column (cities) in a MySQL table (locations) 2. Make those values the only options in the dropdown menu. Any ideas how I would do this? This is what I have so far. <label for="city">What is your destination city?</label> <select class="form-control" id="city" name="city"> <?php //connect to the database $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); //grab the city names from the MySQL table $query = "SELECT cities FROM locations"; $res = mysqli_query($dbc, $query); while ($data = mysqli_fetch_assoc($res)) { echo '<option value="'.$data['cities'].'">'.$data['cities'].'</option>'; } //close the db connection mysqli_close($dbc); ?> </select> This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=344960.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=321745.0 Hey folks! a two-part problem he PART 1: here's a weird problem i bumped into today. when i leave OUT the 'varTable' section (see the class designations), it generates a table (allbeit messed up for reasons that i'll get into in part 2). but when i put 'varTable' back in, it generates the first array output just fine, but nothing shows for the table. (i need the first to be able to display the array) why does that happen? PART 2: when the table DOES generate, it gives a lot of errors and $i counts up to 7! whaaaaat!? thanks in advance for your help. this has me stumped. i've tried resetting the array, different variable names...nothing worked. i also included the array output at the very bottom. seems like a lot of extra data in there to me...and the [ 0 ] is printing oddly here (spaces prevent odd formatting...). WR! DATABASE TABLE: | id | item | cost | use | -------------------------------- | 0 | basket | 35 | 1 | | 1 | bicycle | 165 | 1 | | 2 | glass | 5 | 1 | | 3 | running shoe | 156 | 1 | | 4 | silver | 300 | 1 | PHP CODE: Code: [Select] <?php include("constants.php"); <?php $connexion = mysql_connect(DB_SERVER, DB_USER, DB_PASS); if(!$connexion) { die("Database Connection Failed: ".mysql_error()); } $selectDB = mysql_select_db("DB_CHOICE", $connexion); if(!$selectDB) { die("Database Selection Failed: ".mysql_error()); } $query = "SELECT * "; $query .= "FROM basic_table"; $results = mysql_query($query, $connexion); if(!$results) { die("Database Query Failed: ".mysql_error()); } ?> <div> <pre class="varTable"> <?php while($checkTable = mysql_fetch_array($results)) { print_r($checkTable); } ?> </pre> </div> <br><br> <div id='codeBlock'> <table class='phpTable' width='500' cellpadding="10"> <?php // generate table header row while ($tableRow = mysql_fetch_array($results)) { echo "<tr>"; for($i=0; $i<count($tableRow); $i++) { echo "<td>" . $tableRow[$i] . "</td>"; } echo "</tr>\n"; } ?> </table> ARRAY OUPUT: Code: [Select] Array ( [0] => 1 [id] => 1 [1] => basket [item] => basket [2] => 35 [cost] => 35 [3] => 1 [usable] => 1 ) Array ( [0] => 2 [id] => 2 [1] => bicycle [item] => bicycle [2] => 165 [cost] => 165 [3] => 1 [usable] => 1 ) Array ( [0] => 3 [id] => 3 [1] => glass [item] => glass [2] => 5 [cost] => 5 [3] => 1 [usable] => 1 ) Array ( [0] => 4 [id] => 4 [1] => running shoe [item] => running shoe [2] => 14 [cost] => 14 [3] => 1 [usable] => 1 ) Array ( [0] => 5 [id] => 5 [1] => silver [item] => silver [2] => 300 [cost] => 300 [3] => 1 [usable] => 1 ) I am trying to write out a calendar style html table with data in each cell, and with a column on the left that shows the times. Basically it should look like this when written out to the webpage: Time Mon Tues Wed Thur Fri Sat 8:00 data data2 9:30 data3 data4 10:00 data5 data6 11:00 data7 data8 The times on the left will vary each month, and the 'data' (these are actually fitness classes held each month) will appear on various days of the week. There is no need to toggle from one month to the next and such, it's just a listing of the current month to display the classes held on which days and at which times. Very easy to do statically in html, but a bit more challenging dynamically. Using MySQL, the table that holds the data looks like this: Code: [Select] schedule_id class_time class_title day_order 1 08:00 data 1 2 08:00 data2 3 3 09:30 data3 2 4 09:30 data4 4 5 10:00 data5 3 6 10:00 data6 5 7 11:00 data7 1 8 11:00 data8 3 The day_order field corresponds to the weekday - Mon is 1, Tues is 2, etc. My query looks like this: Code: [Select] SELECT schedule_id, class_time, class_title, day_orderFROM `class_schedule` order by class_time, day_order Here is the html/ php code to write it out: Code: [Select] <table border="0" cellpadding="2" cellspacing="0" width="625"> <tr> <td class="calheader">Time</td> <td class="calheader">Mon</td> <td class="calheader">Tue</td> <td class="calheader">Wed</td> <td class="calheader">Thu</td> <td class="calheader">Fri</td> <td class="calheader">Sat</td> <td class="calheader">Sun</td> </tr> <? $i=0; $first_time = ""; while($i<$num_rows){ $sid = mysql_result($sql,$i,"schedule_id"); $ctime = mysql_result($sql,$i,"class_time"); $cdate = mysql_result($sql,$i,"CURDATE()"); $strtime = date("h:i:s",$cdate.$ctime); $ctitle = stripslashes(mysql_result($sql,$i,"class_title")); $order = mysql_result($sql,$i,"day_order"); if ($ctime != $first_time){ if (isset($first_time)){ echo ""; } if ($first_time == ""){ echo "<tr>\n"; echo "<td class=\"timecell\">". $ctime ."</td>\n"; } $first_time = mysql_result($sql,$i,"class_time"); } $j = 1; while ($j<8 && $first_time != ""){ if ($order == $j){ $thetitle = $ctitle; } else { $thetitle = " "; } echo "<td class=\"calcell\">". $thetitle ."</td>\n"; $j++; } unset($first_time); if (!isset($first_time)) { echo "</tr>\n"; } $i++; } unset($ctitle); unset($thetitle); unset($weekday); unset($sid); unset($clink); unset($order); mysql_close(); The above code sort of works, but the trouble I am having is that it is creating a new table row for each class, even if they occur at the same time slot. It should be putting them on the same row, to the right of the time slot across the days of the week. If anyone could assist, that would be wonderful - I am really stuck with this... Thanks Hello, I am making a small CMS and I having some trouble with making a dynamic menu. I am wondering for a few days how I should make this menu system. I have the follow MySQL table: Code: [Select] CREATE TABLE `pages` ( `id` int(4) unsigned NOT NULL AUTO_INCREMENT, `time` varchar(10) DEFAULT NULL, `lastby` varchar(2) DEFAULT NULL, `order_id` varchar(2) DEFAULT NULL, `text` text, PRIMARY KEY (`id`) ) ENGINE=InnoDB; Now I would like to have a menu system as following that I make menu's in a menu table with a name and a menu ID and that I could place those pages as parent or as subparent. How could I manage to turn my theory into reality? This topic has been moved to Apache HTTP Server. http://www.phpfreaks.com/forums/index.php?topic=320065.0 This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=358814.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=307157.0 Dear all friends, I don't know this forum already have kindly of this question or not. I'm coding my won php and mysql. but I have no idea with two wanted idea as below: 1. when I post on my website. It will automaticall post in my page in facebook 2. when friend in facebook comment on that item it will also show that comment on my facebook page and also my website too. I'm please to getting your idea event from general idea and technical idea. thanks for your answer. All of your answer and idea very important to me. Best Regards Steve. I have practically no experience with PHP but I know how to use mysql. Anyway I am trying to set up registration for a game through my website, so would something simple like this work, provided I can figure how to tell it what database and table to input the information in?
HI. I am talking about this website. http://www.elfster.com/ Please browse this website. Can any one tell me how database structure / queries will work? (i know PHP / MYSQL) Can any one guide me a little bit. I would really appreciate it, Thanks Waiting for reply. Sorry for my bad english but i hope you would understand my query. How can i set 404 not found for database driven pages..? I am using header("HTTP/1.0 404 Not Found"); in my 404 error page and ErrorDocument 404 /404.html, whereas 404.html is my error page. i have an URL http://www.example.com/folder/my-test-for-url-95/ which is opening correctly because it has existence on database. but when i am opening http://www.example.com/folder/my-test-for-url-951/ which has existence on database is also opening without any information but i want here a 404 not found page. How can i do so. Thanks |