PHP - Populate Menu
Hello, I am running into a problem. I am trying to convert :
Code: [Select] $queryyp = "SELECT YEAR(date) as year, MONTHNAME(date) as month, title FROM post ORDER BY date DESC"; // query to get the rows you want in the order that you want them, with the year and monthname specifically selected as well $resultyp = mysql_query($queryyp); $last_heading = null; // remember the last heading (initialize to null) while($rowyp = mysql_fetch_assoc($resultyp)){ $new_heading = $rowyp['year']; // get the column in the data that represents the heading $new_subheading = $rowyp['month']; // get the column in the data that represents the subheading if($last_heading != $new_heading){ // heading changed or is the first one $last_heading = $new_heading; // remember the new heading $last_subheading = null; // (re)initialize the subheading // start a new section, output the heading here... echo "{$rowyp['year']}<br />"; } // subheading under each heading if($last_subheading != $new_subheading){ // subheading changed or is the first one $last_subheading = $new_subheading; // remember the new subheading // start a new section, output the subheading here... echo " {$rowyp['month']}<br />"; } // output each piece of data under a heading here... echo " {$rowyp['title']}<br />"; } And be able to put it in a javascript tree with very little luck: Code: [Select] <ul id="yeartree" class="tree"> <li>{$rowyp['year']} <ul> <li>{$rowyp['month']} <ul> <li>{$rowyp['title']}</li> </ul> </li> </ul> </li> Yes I know the phpcode in the tree is not correct. That is just an example of what I am attempting to do. I can get the tree to display without the js but I need to add it to js due to the amount of entries and need to beable to collapse it. Similar TutorialsHi there, i am relatively new to php, mysql, css etc but learning fast. My problem is such; i have a php file which is doing a SELECT mysql_query, WHILE results to strings, then ECHO the resulting rows to produce a list formatted using <table> and finally this <table> is inside a <form> which will POST the changes back to the specific database.tble.row. I wish to have a drop down menu within the <form><table> which will be populated from a separate database.table. I have accomplished the drop down menu outside the <?php ?> tags inside <form><table> which POSTS to a php file but my problem is to add the populating drop down menu inside <?php ?> an already ECHOing resulting rows from the sql query. i.e <?php blurb and stuff ?> <form><table><tr><td> <select name etc> <?php $result = mysql_query("SELECT * FROM tbl WHERE string = tble.rw ORDER BY column"); while($row=mysql_fetch_array($result)){ echo "<OPTION VALUE=".$row['column'].">".$row['column']."</OPTION>"; } ?> </select> WORKS!!!! but placing this inside <?php $x =mysql_query[select] while {strings = conditions; echo ("<form><table><tr><td> insert populated drop menu here </td> etc "); echo"";}?> doesnt work and just leaves the select drop menu blank Hoep you understand my problem. I do not think i can attached the population WHILE loop to a string and just insert the string to the form but maybe i am wrong. thanks in advance and if you go tthis far reading you must be on lots and lots of coffee zark I am currently creating a form and I want to populate a drop down selection menu with data from two fields in a form. For example, I want it to pull the first and last name fields from a database to populate names in a drop down menu in a form. I want the form to submit to the email address of the person selected in the drop down. Is this possible to do? The email is already a field in the record of the person in the database. Can anyone give me some pointers or advice on how I should go about setting up the "Select" box drop down? I am not sure how to code it to do what I am wanting. Any links to relevant help would be appreciated too. Thanks in advance! Hey Guys, I know it may seem pretty simple, but im having trouble populating a drop down list. Here is my code at the moment, but what it's doing is displaying the names all in one value, where it should be in separate select values. *Note that i have only done it to the first one. See attachment. 'AntonMatt' are next to each other, they should be separate select values. Code: [Select] <? $id = $_GET['id']; $selectplayers="SELECT * FROM players WHERE club='$club' AND team='$team'"; $player=mysql_query($selectplayers); ?> <table class='lineups' width="560" cellpadding="5"> <tr> <td colspan="2">Starting Lineup</td> <td colspan="2">On the Bench</td> </tr> <tr> <td width="119"> </td> <td width="160"> </td> <td width="69"> </td> <td width="160"> </td> </tr> <tr> <td>Prop</td> <td><select name="secondary" style="width: 150px"> <option value='' selected="selected"><? while($rowplayer = mysql_fetch_array($player)) { echo $rowplayer['fname']; } ?></option> </select></td> <td>16.</td> <td><select name="secondary16" style="width: 150px"> <option value='' selected="selected">Secondary Position</option> </select></td> </tr> <tr> <td style="padding-top: 8px;">Hooker</td> <td style="padding-top: 8px;"><select name="secondary2" style="width: 150px"> <option value='' selected="selected">Secondary Position</option> </select></td> <td style="padding-top: 8px;">17.</td> <td style="padding-top: 8px;"><select name="secondary17" style="width: 150px"> <option value='' selected="selected">Secondary Position</option> </select></td> </tr> </table> </div> </div> Hey Guys I have the following table: (login) I need that table to be echoed he But it needs to filter it for the school they are logged in as. Help: When they login they have to select what school they are at so you can use that code. example: PHS = Poole High School Hi All,
I have a AmChart file, but unfortunately this data is static. I would like to make this data more dynamic by populating it from a PHP file. Please can someone direct me in doing this?
Here is the AmChart page Code:
<!DOCTYPE html> <html> <head> <title>Climate Survey Results</title> <!-- amCharts javascript sources --> <script type="text/javascript" src="http://cdn.amcharts.com/lib/3/amcharts.js"></script> <script type="text/javascript" src="http://cdn.amcharts.com/lib/3/serial.js"></script> <!-- amCharts javascript code --> <script type="text/javascript"> AmCharts.makeChart("chartdiv", { "type": "serial", "categoryField": "category", "angle": 45, "depth3D": 10, "startDuration": 0.5, "theme": "default", "categoryAxis": { "gridPosition": "start" }, "trendLines": [], "graphs": [ { "fillAlphas": 1, "fillColors": "#008000", "id": "very_satisfied", "lineColor": "#008000", "title": "Very Satisfied", "type": "column", "valueField": "Very Satisfied" }, { "fillAlphas": 1, "fillColors": "#0000FF", "id": "satisfied", "lineColor": "#0000FF", "title": "Satisfied", "type": "column", "valueField": "Satisfied" }, { "fillAlphas": 1, "fillColors": "#FF8000", "fontSize": 0, "id": "dissatisfied", "lineColor": "#FF8000", "title": "Dissatisfied", "type": "column", "valueField": "Dissatisfied" }, { "fillAlphas": 1, "fillColors": "#CC0000", "id": "very_dissatisfied", "lineColor": "#CC0000", "title": "Very Dissatisfied", "type": "column", "valueField": "Very Dissatisfied" } ], "guides": [], "valueAxes": [ { "id": "ValueAxis-1", "stackType": "100%", "title": "Percentage Scored (%)" } ], "allLabels": [], "balloon": {}, "legend": { "textClickEnabled": false, "useGraphSettings": false, "valueAlign": "centre" }, "titles": [ { "size": 20, "text": "Climate Survey Results" } ], "dataProvider": [ { "category": "1", "Very Satisfied": 4.69, "Satisfied": 65.63, "Dissatisfied": 23.43, "Very Dissatisfied": 6.25 }, { "category": "2", "Very Satisfied": 3.13, "Satisfied": 46.88, "Dissatisfied": 34.37, "Very Dissatisfied": 15.62 }, { "category": "3", "Very Satisfied": 1.56, "Satisfied": 56.25, "Dissatisfied": 32.81, "Very Dissatisfied": 9.38 }, { "category": "4", "Very Satisfied": 7.81, "Satisfied": 56.25, "Dissatisfied": 28.13, "Very Dissatisfied": 7.81 }, { "category": "5", "Very Satisfied": 7.81, "Satisfied": 35.94, "Dissatisfied": 43.75, "Very Dissatisfied": 12.5 }, { "category": "6", "Very Satisfied": 26.56, "Satisfied": 57.81, "Dissatisfied": 12.5, "Very Dissatisfied": 3.13 }, { "category": "7", "Very Satisfied": 10.94, "Satisfied": 43.75, "Dissatisfied": 28.13, "Very Dissatisfied": 17.19 }, { "category": "8", "Very Satisfied": 28.13, "Satisfied": 53.13, "Dissatisfied": 14.06, "Very Dissatisfied": 4.69 }, { "category": "9", "Very Satisfied": 26.56, "Satisfied": 64.06, "Dissatisfied": 7.81, "Very Dissatisfied": 1.56 }, { "category": "10", "Very Satisfied": 21.88, "Satisfied": 46.88, "Dissatisfied": 28.13, "Very Dissatisfied": 3.13 }, { "category": "11", "Very Satisfied": 1.56, "Satisfied": 43.75, "Dissatisfied": 45.31, "Very Dissatisfied": 9.38 }, { "category": "12", "Very Satisfied": 1.56, "Satisfied": 39.06, "Dissatisfied": 40.63, "Very Dissatisfied": 18.75 }, { "category": "13", "Very Satisfied": 3.13, "Satisfied": 43.75, "Dissatisfied": 31.25, "Very Dissatisfied": 21.87 }, { "category": "14", "Very Satisfied": 23.44, "Satisfied": 62.5, "Dissatisfied": 12.5, "Very Dissatisfied": 1.56 }, { "category": "15", "Very Satisfied": 9.38, "Satisfied": 53.12, "Dissatisfied": 35.94, "Very Dissatisfied": 1.56 } ] } ); </script> </head> <body> <div id="chartdiv" style="width: 50%; height: 400px; " ></div> </body> </html>My PHP returns the following: Array ( [0] => Array ( [Question] => 1. Overall how satisfied are you with your role / position at Altech Autopage? [Very Satisfied] => 4.6875 [Satisfied] => 65.6250 [Dissatified] => 23.4375 [Very Dissatisfied] => 6.2500 ) [1] => Array ( [Question] => 2. Employees are recognized as individuals. [Very Satisfied] => 3.1250 [Satisfied] => 46.8750 [Dissatified] => 34.3750 [Very Dissatisfied] => 15.6250 ) [2] => Array ( [Question] => 3. Employees are highly motivated to see the company succeed. [Very Satisfied] => 1.5625 [Satisfied] => 56.2500 [Dissatified] => 32.8125 [Very Dissatisfied] => 9.3750 ) [3] => Array ( [Question] => 4. Customer Operations clearly communicates its goals and strategies. [Very Satisfied] => 7.8125 [Satisfied] => 56.2500 [Dissatified] => 28.1250 [Very Dissatisfied] => 7.8125 ) [4] => Array ( [Question] => 5. Customer Operations offers clear opportunities for career advancement. [Very Satisfied] => 7.8125 [Satisfied] => 35.9375 [Dissatified] => 43.7500 [Very Dissatisfied] => 12.5000 ) [5] => Array ( [Question] => 6. My job responsibilities are clear. [Very Satisfied] => 26.5625 [Satisfied] => 57.8125 [Dissatified] => 12.5000 [Very Dissatisfied] => 3.1250 ) [6] => Array ( [Question] => 7. Management is sensitive to employee problems. [Very Satisfied] => 10.9375 [Satisfied] => 43.7500 [Dissatified] => 28.1250 [Very Dissatisfied] => 17.1875 ) [7] => Array ( [Question] => 8. My immediate supervisor provides a positive role model. [Very Satisfied] => 28.1250 [Satisfied] => 53.1250 [Dissatified] => 14.0625 [Very Dissatisfied] => 4.6875 ) [8] => Array ( [Question] => 9. Your own morale. [Very Satisfied] => 26.5625 [Satisfied] => 64.0625 [Dissatified] => 7.8125 [Very Dissatisfied] => 1.5625 ) [9] => Array ( [Question] => 10. The team spirit and level of cooperation among workers. [Very Satisfied] => 21.8750 [Satisfied] => 46.8750 [Dissatified] => 28.1250 [Very Dissatisfied] => 3.1250 ) [10] => Array ( [Question] => 11. The amount of recognition you receive for your work. [Very Satisfied] => 1.5625 [Satisfied] => 43.7500 [Dissatified] => 45.3125 [Very Dissatisfied] => 9.3750 ) [11] => Array ( [Question] => 12. The compensation you receive for your work. [Very Satisfied] => 1.5625 [Satisfied] => 39.0625 [Dissatified] => 40.6250 [Very Dissatisfied] => 18.7500 ) [12] => Array ( [Question] => 13. Your overall level of job security. [Very Satisfied] => 3.1250 [Satisfied] => 43.7500 [Dissatified] => 31.2500 [Very Dissatisfied] => 21.8750 ) [13] => Array ( [Question] => 14. The professionalism of your immediate supervisor. [Very Satisfied] => 23.4375 [Satisfied] => 62.5000 [Dissatified] => 12.5000 [Very Dissatisfied] => 1.5625 ) [14] => Array ( [Question] => 15. Overall, how would you rate Customer Operations as an area to work. [Very Satisfied] => 9.3750 [Satisfied] => 53.1250 [Dissatified] => 35.9375 [Very Dissatisfied] => 1.5625 ) ) Which is the same result as I am currently entering manually. how do I populate the textbox values in form.html? Thanks in advance for any help you might offer. Code: [Select] //formfill.php <?php $hours="akj"; //split string characters to array $hours_array = str_split($hours); //iterate through the characters in the array foreach($hours_array as $char) { echo($char."<br />"); //somehow populate text boxes in form.html } ?> //form.html <html> <body> <form> <table> <tr> <td><input type="text" name="hour[0]" value="" /></td> <td><input type="text" name="hour[1]" value="" /></td> <td><input type="text" name="hour[2]" value="" /></td> </tr> </table> </form> </body> </html> Hey everyone. I have some experience with PHP and can easily modify existing code, but seem to have trouble writing the logic from scratch. Situation: I'm using this Jquery slider ( http://mine.tuxfamily.org/?p=74#more-74 ) and would like to populate the slides with data coming from an XML file. The data will be text, images(URIs), and links to buy. The thing is, each slide will hold 4 items, and then I want to somehow using PHP logic, allow the code to generate the next slide... In other words, how would I code it so that after 4 entries, it creates a new slide? I'm imagining a For loop + SimpleXML functions... but just kind of fumbling in the dark here. Any direction or guidance is greatly appreciated! Kind regards, Dey I am working on a web app, here's the page I am on : http://sa.uintramural.com/autoselect/timeslip.php The fields choices are being pulled from a database. What I am trying to do is when someone types in a name and selects that person that it would look in the table for the 'Terms' and pull whatever value there is for that person and choose it automatically in the drop down menu. Could you point me in the right direction to do that or show me a code snippet. Thanks original sql Code: [Select] -- -------------------------------------------------------- -- -- Table structure for table `countries` -- CREATE TABLE `countries` ( `id` int(6) NOT NULL auto_increment, `value` varchar(250) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=243 ; -- -- Dumping data for table `countries` -- INSERT INTO `countries` VALUES (1, 'Vancouver'); New Sql Code: [Select] -- -------------------------------------------------------- -- -- Table structure for table `countries` -- CREATE TABLE `countries` ( `id` int(6) NOT NULL auto_increment, `value` varchar(250) NOT NULL default '', `code` varchar(12) NOT NULL default '', PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=243 ; -- -- Dumping data for table `countries` -- INSERT INTO `countries` VALUES (1, 'Vancouver', 'BC-50'); PHP code for the job Code: [Select] <?php // PHP5 Implementation - uses MySQLi. // mysqli('localhost', 'yourUsername', 'yourPassword', 'yourDatabase'); $db = new mysqli('localhost', 'root' ,'password', 'weather'); if(!$db) { // Show error if we cannot connect. echo 'ERROR: Could not connect to the database.'; } else { // Is there a posted query string? if(isset($_POST['queryString'])) { $queryString = $db->real_escape_string($_POST['queryString']); // Is the string length greater than 0? if(strlen($queryString) >0) { // Run the query: We use LIKE '$queryString%' // The percentage sign is a wild-card, in my example of countries it works like this... // $queryString = 'Uni'; // Returned data = 'United States, United Kindom'; // YOU NEED TO ALTER THE QUERY TO MATCH YOUR DATABASE. // eg: SELECT yourColumnName FROM yourTable WHERE yourColumnName LIKE '$queryString%' LIMIT 10 $query = $db->query("SELECT your_column FROM your_db_table WHERE your_column LIKE '$queryString%' LIMIT 10"); if($query) { // While there are results loop through them - fetching an Object (i like PHP5 btw!). while ($result = $query ->fetch_object()) { // Format the results, im using <li> for the list, you can change it. // The onClick function fills the textbox with the result. // YOU MUST CHANGE: $result->value to $result->your_colum echo '<li onClick="fill(\''.$result->value.'\');">'.$result->value.'</li>'; } } else { echo 'ERROR: There was a problem with the query.'; } } else { // Dont do anything. } // There is a queryString. } else { echo 'There should be no direct access to this script!'; } } ?> What the original code does 1) you start typing your city (eg. Van) 2) when you type the first letter (eg. V), it looks into mysql and auto fills a dropdown menu with all possible cities What i need it to do 1) you start typing your city (eg. Van) 2) when you type the first letter (eg. V), it looks into mysql and auto fills a dropdown menu with all possible cities 3) when you find your city you click it or press enter, and it POST's the city code as well now how do i munipulate the script to do that... another thing, when i put the extra sql entry in "code", the auto fill stopped working, why? Thanks hi all,i have a php form that i would like to populate from a drop down list,my problem is that i cant place the drop down list at the correct place.what i want is that where the franchisee is the input should be the drop down,please help....this is the code that i am using Code: [Select] <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <p>Add a Bus in the Bus table.</p> <p> Fleet Number:<br /> <input type="text" name="fleet_number" size="6" maxlength="10" value="" /> </p> <p> Registration Number:<br /> <input type="text" name="registration_number" size="10" maxlength="20" value="" /> </p> <p> Model:<br /> <input type="text" name="model" size="10" max length="15" value="" /> </p> <p> Franchisee :<br /> <input type="select" name="franchisee_id" size="10" max length="15" value="" /> <select name=dropdown_list> <?php while($row = oci_fetch_array($stid)) { echo "<option value='".$row['FRANCHISEE_NAME']."'>"; echo $row['FRANCHISEE_NAME']; echo "</option> "; } ?> </select> </p> <p> <input type="Submit" name="submit" value="Submit !" /> </p> </form> I have a div on my webpage that will contain an error message, basically 'username or password incorrect.' At the moment on the login page I have the div containing: Code: [Select] <div id="errorMessage"><?php echo $errorMessage; ?></div> and in the php code i have: Code: [Select] $errorMessage = ""; if(isset($_POST['username'])) { // check if username and password exists // else $errorMessage = "username or password incorrect"; } but unfortunately this doesn't seem to show on the page, any ideas? i am trying to get the allowed file types from the database into a switch statement but with no luck so far. They types are in the database like: jpg, png, gif. All seperated with a comma and all in one db column. I am then splitting them at the comma and inserting them into $file_list. In the switch statement i want it to be like: switch($ext) { case "jpg": case "png": case "gif": break; } how can i make this possible? here is my code so far: $ext = strtolower(pathinfo($_FILES['Filedata']['name'], PATHINFO_EXTENSION)); $f_types = $f_types_info['file_types']; $f_types = preg_split("|\,|", $f_types); $types = count($f_types); $file_list = ""; for($i=0; $i<$types; $i++) { $file_list .= $f_types[$i]; } switch ($ext) { case $file_list: break; default: $error = "File Type Not Allowed"; break; } I have two scripts. One uses a drop down list to populate a forum while the other makes you enter in a value and populates the forum below with all the data in that table where the input matches the requested number. So lets get down to it shall we? 1st up we have a movies list. <?php include('CheckLogin.php'); include ('databaseconfig.php'); $query = mysql_query("select title from movies"); if (isset($_POST['submitSearch'])) { $query2 = mysql_query("select * from movies where title = ". $_POST['list']); } ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Home </title> <script type="text/javascript" src="javaScript/jquery-min.js"></script> <script type="text/javascript" src="javaScript/corners.js"></script> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="wrapper"> <header> <div id="header"> <h1 id="logo">RAY AND CARLS </h1> <p class="description"><?php echo check();?><br/> </p> </div> </header> <nav> <ul id="nav"> <li> <a href="index.php">Home </a> </li> <li> <a href="#">Customer Registration </a> </li> <li> <a href="#">View Movies </a> </li> <li> <a href="#">View Games </a> </li> <li> <a href="#">Rent </a> </li> <li> <a href="#">Login </a> </li> <li> <a href="#">Admin </a> </li> </ul> </nav> <article> <section> <div class="cornerBox cBox3"> <div class="cornerBox-content"> <div class="List"> <form class="cmxform" id="commentForm" action="action" method="post"> <p> <select name="list"> <?php while ($row = mysql_fetch_array($query)) { echo "<option>$row[title]</option>\n"; } ?> </select> </p> <p><input name="submitSearch" type="button" value="submit"></p> </form> <p> </p> <form class="cmxform" id="commentForm" action="action" method="post"> <h2>The Movie Selected </h2> <p> <?php while ($row2 = mysql_fetch_array($query2)){?> <label for="cname">Movie ID: </label> <em>* </em> <input id="cname" name="movieid" size="4" class="required" minlength="2" value="<?php echo $row2[0];?>"> </p> <p> <label for="cemail">Rented <em> 0 for n, 1 for y</em> </label> <em>* </em> <input id="cemail" name="rented" size="2" class="required email" value="<?php echo $row2[1];?>"> </p> <p> <label for="curl">Title </label> <em>* </em> <input id="curl" name="title" size="30" class="url" value="<?php echo $row2[2];?>"> </p> <p> <label for="curl">Category </label> <em>* </em> <input id="curl" name="category" size="15" class="url" value="<?php echo $row2[3];?>"> </p> <p> <label for="curl">Director </label> <em>* </em> <input id="curl" name="director" size="15" class="url" value="<?php echo $row2[4];?>"> </p> <p> <label for="curl">Leading Actors </label> <em>* </em> <input id="curl" name="leadingactors" size="50" class="url" value="<?php echo $row2[5];?>"> </p> <p> <label for="curl">Supporting Actors </label> <em>* </em> <input id="curl" name="supportingactors" size="50" class="url" value="<?php echo $row2[6];?>"> </p> <p> <label for="curl">Run Time <em>in minutes</em> </label> <em>* </em> <input id="curl" name="runtime" size="4" class="url" value=""><?php echo $row2[7];?></input> </p> <p> <label for="curl">Rating </label> <em>* </em> <input id="curl" name="rating" size="6" class="url" value="<?php echo $row2[8];?>"> </p> <p> <label for="curl">Release Date </label> <em>* </em> <input id="curl" name="releasedate" size="10" class="url" value="<?php echo $row2[9];?>"> <?php } ?> </form> </div> </div> </div> </section> </article> <footer> <div id="footer"> <div class="footer1"> <h2> About </h2> <p> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. </p> </div> <div class="footer2"> <h2>Other places </h2> <p> <ul> <li> <a href="#">Link 1 </a> </li> <li> <a href="#">Link 2 </a> </li> <li> <a href="#">Link 3 </a> </li> <li> <a href="#">Link 4 </a> </li> </ul> </p> </div> <div class="footer3"> <h2> Other information </h2> <p> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. </p> </div> <p class="credits">© <a href="http://bwshome.byethost5.com/blogs">Adam Balan - BLACKANDWHITE </a> <span>• </span> Powered by <a href="http://bwshome.byethost5.com/blogs">BLACKANDWHITE </a> <span>• </span> </div> </footer> </div> </body> </html>] This script populates a list with movie names with the select statement of select * from movies; What I want to do is select a movie from this list and have the page refresh with a forum full of the details based on the movie title, hence the select * from movies where title = title statement. What it currently does is populates a drop down list with titles of movies in the data base but not the forum.... 2nd up we have the customer details The second script is similar but now we want to populate a forum based on user input of a customer id. So lets say we have an ID of 10, we enter 10 hit enter and the forum bellow should populate with all the customer info based on that id allowing me to edit and update (I haven't got to the update part yet, still trying to populate a forum) <?php session_start(); include('CheckLogin.php'); include('databaseconfig.php'); if (isset($_POST['searchSubmit'])) { $query = mysql_query("select * from customer where customer_id =".$_POST['cust_id']); } ?> <!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Home </title> <script type="text/javascript" src="javaScript/jquery-min.js"></script> <script type="text/javascript" src="javaScript/corners.js"></script> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> </script> <link href="style.css" rel="stylesheet" type="text/css"> </head> <body> <div id="wrapper"> <header> <div id="header"> <h1 id="logo">RAY AND CARLS </h1> <p class="description"> <?php echo checkAdmin();?> <br/> </p> </div> </header> <nav> <ul id="nav"> <li> <a href="index.php">Home </a> </li> <li> <a href="#">Customer Registration </a> </li> <li> <a href="#">View Movies </a> </li> <li> <a href="#">View Games </a> </li> <li> <a href="#">Rent </a> </li> <li> <a href="#">Login </a> </li> <li> <a href="#">Admin </a> </li> </ul> </nav> <article> <section> <div class="cornerBox cBox3"> <div class="cornerBox-content"> <p>All updates to the Data base can be done here. Keeping in mind specific relationships with The back end data bases. </p> <p>Some common tasks are below. This page allows you to add, edit and delete customers/movies and games. </p> <div class="cornerBox2 cBox3"> <div class="cornerBox-content"> <h1>Menu </h1> <ul> <h2>Customers </h2> <li> <a href="#">edit </a> </li> <li> <a href="#">Add New </a> </li> <h2>Movies </h2> <li> <a href="#">edit </a> </li> <li> <a href="#">Add New </a> </li> <h2>Games </h2> <li> <a href="#">edit </a> </li> <li> <a href="#">Add New </a> </li> </ul> </div> </div> <div class="Forum"> <h2>Search</h2> <form class="cmxform" id="commentForm" method="post" action=""> <p> <label for="cname">Customer ID: </label> <em>* id's must be > 0 </em> <input id="cname" name="cust_id" size="25" class="required" minlength="2" /> </p> <p> <input class="submit" type="submit" value="Submit" name="searchSubmit"/> </p> </form> <h2>Edit Customer </h2> <?php $resualt = mysql_query($query); while($row = mysql_fetch_array($resualt)) { ?> <form class="cmxform" id="commentForm" method="post" action=""> <p> <label for="cname">Customer ID: </label> <em>* </em> <input id="cname" name="cust_id" size="25" class="required" minlength="2" value="<?php $row[0]?>"/> </p> <p> <label for="cemail">First Name </label> <em>* </em> <input id="cemail" name="fname" size="25" class="required email" value="<?php $row[1]?>"/> </p> <p> <label for="curl">Last Name </label> <em>* </em> <input id="curl" name="lastname" size="25" class="url" value="<?php $row[2]?>"/> </p> <p> <label for="curl">Address </label> <em>* </em> <input id="curl" name="address" size="25" class="url" value="<?php $row[3]?>"/> </p> <p> <label for="curl">Postal Code </label> <em>* </em> <input id="curl" name="postalcode" size="7" class="url" value="<?php $row[4]?>"/> </p> <p> <label for="curl">Phone Number </label> <em>* </em> <input id="curl" name="phonenumber" size="11" class="url" value="<?php $row[5]?>""/> </p> <p> <input class="submit" type="submit" value="Submit" name="submit"/> </p> </form> <?php } ?> <?php if (!mysql_query($query)) { echo("<h1>Possible Errors </h1>"); //Echo errors echo mysql_error(); echo ("<p>"); } else { echo("<h2>Customer was added</h1>"); } ?> </div> </div> </div> </section> </article> <footer> <div id="footer"> <div class="footer1"> <h2> About </h2> <p> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. </p> </div> <div class="footer2"> <h2>Other places </h2> <p> <ul> <li> <a href="#">Link 1 </a> </li> <li> <a href="#">Link 2 </a> </li> <li> <a href="#">Link 3 </a> </li> <li> <a href="#">Link 4 </a> </li> </ul> </p> </div> <div class="footer3"> <h2> Other information </h2> <p> Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. </p> </div> <p class="credits">© <a href="http://bwshome.byethost5.com/blogs">Adam Balan - BLACKANDWHITE </a> <span>• </span> Powered by <a href="http://bwshome.byethost5.com/blogs">BLACKANDWHITE </a> <span>• </span> </div> </footer> </div> </body> </html> Now when I enter 10 into the search I get an error of: "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Resource id #5' at line 1" I was told to make another thread for my question(s) and since these are in relation to each other (populating a forum and all) I thought it best to combine two into one. This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=351349.0 I have a table that allows users to add rows, depending on how much data they need to insert. upon submit I'd like to populate another table for review. Now I can generate the data, but I'm having trouble putting the array into a table. Here is the output from the initial page: Code: [Select] Array ( [quantity] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [description] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [unit_cost] => Array ( [0] => 1 [1] => 2 [2] => 3 ) [shipping] => 4 [tax] => 5 [review_po] => Review ) I need it to look like this: Quantity | Description | Unit Cost 1 | 1 | 1 2 | 2 | 2 3 | 3 | 3 Tax | 4 Ship | 5 I think it's a foreach statement, but I'm not having any luck.. If someone could point me in the right direction??? hey guys i can't seem to get my second list box to work? the first one is good it shows the brands but the second one does not show at all? i have 2 DB Brands and others products so in brands i have id and name .. second i have product_id-product_Nand Brand this is my query(select the brand then it list the products that are associated with the brand) <?php $Brand_N = $Product_N = null; //declare vars $conn = mysql_connect("localhost", "2", "2"); $db = mysql_select_db('2',$conn); if(isset($_POST["Brand_N"]) && is_numeric($_POST["Brand_N"])) { $Brand_N = $_POST["Brand_N"]; } if(isset($_POST["Product_N"]) && is_numeric($_POST["Product_N"])) { $Product_N = $_POST["Product_N"]; } ?> <script language="JavaScript"> function autoSubmit() { var formObject = document.forms['theForm']; formObject.submit(); } </script> <form name="theForm" method="post"> <select name="brand" onChange="autoSubmit();"> <option value="Brand">Brand</option> <?php $sql = "SELECT * FROM Brand"; $Brand = mysql_query($sql,$conn); while($row = mysql_fetch_array($Brand)) { echo ("<option value=\"$row[Brand_id]\" " . ($Brand_N == $row["Brand_N"]? " selected" : "") . ">$row[Brand_N]</option>"); } ?> </select> <?php if($Brand_N!= null && is_numeric($Brand_N)) { ?> <select name="Product" onChange="autoSubmit();"> <option value="Product">Product</option> <?php $sql = "SELECT * FROM products WHERE Brand = $Brand_N "; $Products = mysql_query($sql,$conn); while($row = mysql_fetch_array($Products)) { echo ("<option value=\"$row[Product_id]\" " . ($Product_N == $row["Product_N"]? " selected" : "") . ">$row[Products_N]</option>"); } ?> </select> </form> <?php } ?> I have this code: echo "<td><a href = 'https://whatismyipaddress.com/ip-lookup' target = '_blank'>$col</a></td>"; the textbox I want to populate on the page has name attribute "LOOKUPADDRESS". it has no id attribute. after clicking on the link, is it possible to fill the textbox with $col? Hey there I just started out with PHP so it might be a trivial problem. I want to populate an array with values by a recursive function but i don't get it the way i want it to have. Target array (written in python syntax): myArray = { key : [ [a1, a2, a3, a4], [b1, b2, b3 ,b4] ], key2 : [ [c1, c2, c3, c4], [d1, d2, d3, d4] ] } So far i created a recursive function to collect all data i need for the array but i don't get the right syntax to achieve my target array. What i have so far is following code (snippet): function get_data($main_dir, $items=[], $myArray=[], $depth=0) { global $items; if ($myArray == NULL && depth == 0) { $myArray = array(); } $depth++; $dirHandle = opendir($main_dir); while ($file = readdir($dirHandle)){ if(is_dir($main_dir.$file) && $file != "." && $file != "..") { $new_dir = $main_dir.$file."/"; $items = get_data($new_dir, $items, $myArray, $depth); $myArray = $items[1] $items = $items[0] } else { splitted_dir = preg_split("/\//", $main_dir); key = splitted_dir[2]; file_information = read_out_file($main_dir.$file); information_1 = file_information[0]; information_2 = file_information[1]; myArray = array_merge($myArray, array($key, array($key, $information_1, $information_2, $main_dir, $file)) } } } The array contains all informations i need but the structure of it is not useable. Current output: Array ( [0] => key1 [1] => Array ( [0] => key1 [1] => information_1 [2] => information_2 [3] => ./path/ [4] => filename ) [2] => key1 [3] => Array ( [0] => key1 [1] => information_1 [2] => information_2 [3] => ./path/ [4] => filename ) [4] => key1 [5] => Array ( [0] => key1 [1] => information_1 [2] => information_2 [3] => ./path/ [4] => filename ) [6] => key2 [7] => Array ( [0] => key2 [1] => information_1 [2] => information_2 [3] => ./path/ [4] => filename ) [8] => key2 [9] => Array ( [0] => key2 [1] => information_1 [2] => information_2 [3] => ./path/ [4] => filename ) ) 1 ## IDK why this "1" at the end gets printed out... But what i want to get is this: Array ( [key1] => Array ( Array ( [0] => key1 [1] => information_1 [2] => information_2 [3] => ./path/ [4] => filename ) ) Array ( [0] => key1 [1] => information_1 [2] => information_2 [3] => ./path/ [4] => filename ) ) ) [key2] => Array ( Array ( [0] => key2 [1] => information_1 [2] => information_2 [3] => ./path/ [4] => filename ) ) Array ( [0] => key2 [1] => information_1 [2] => information_2 [3] => ./path/ [4] => filename ) ) ) )
At the end i want to sort the output by alphabetic order of the keys which i should achieve with sort() i guess?
Greetings Edited August 10, 2019 by Sandy_85I have a problem with the following code but i really don't see it: I try to populate the city textfield by the zipcode entered on the zipcode textfield function fillcitystate(controlname) { var zipstring = ""; xmlhttp = new XMLHttpRequest(); xmlhttp.open("GET", "postcode.php?postcode=" + controlname.value, true); xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4) { var zipstring = xmlhttp.responseText; if (zipstring!="Error") { var ziparray = zipstring.split("|"); document.getElementById("test").innerHTML = ziparray[1]; } } } xmlhttp.send(null); } In postcode.php $returnval = "Error"; $postcode = $_GET['postcode']; $query = "SELECT * FROM city WHERE code='$postcode'"; $resultval = mysql_query($query); $rowcount = mysql_num_rows($resultval); if ($rowcount==1) { $row = mysql_fetch_array($resultval); $returnval = $row['code']."|".ucwords(strtolower($row['name']))."|".$row['province']; } else { } echo $returnval; When entering a zipcode, nothing happened so i decided to just echo the name of the city using the innerHTML. Still nothing happened, so i commented out all the php in my postcode.php and decided to just do: $postcode = $_GET['postcode']; echo $postcode; then it printed out: 'undefined' Can somebody point me out? I have a set of 26 checkboxes that are stored in an array. The below code dumps the comma separated array values into a single record column. Code: [Select] // dumping the type of job checkboxes $type = $_POST['type']; var_dump($type); // Setting up a blank variable to be used in the coming loop. $allStyles = ""; // For every checkbox value sent to the form. foreach ($type as $style) { // Append the string with the current array element, and then add a comma and a space at the end. $allTypes .= $style . ", "; } // Delete the last two characters from the string. $allTypes = substr($allTypes, 0, -2); // end dumping the type of job checkboxes This works great! But my needs go past this. The record can be edited. So I need to get the values back out of the database and populate the correct check boxes for editing. The checkboxes are generated by this code. Code: [Select] <div class="text">Job Type (<a class="editlist" href="javascript:editlist('listedit.php?edit=typelist',700,400);">edit list</a>):</div> <div class="field"> <?PHP $connection=mysql_connect ("localhost", "name", "pass") or die ("I cannot connect to the database."); $db=mysql_select_db ("database", $connection) or die (mysql_error()); $query = "SELECT type FROM typelist ORDER BY type ASC"; $sql_result = mysql_query($query, $connection) or die (mysql_error()); $i=1; echo '<table valign="top"><tr><td>'; while ($row = mysql_fetch_array($sql_result)) { $type = $row["type"]; if ($i > 1 && $i % 26 == 0) echo '</td><td>'; else if ($i) echo ''; ++$i; echo "<input style='font-size:10px;' name='type[]' type='checkbox' value='$type'><span style='color:#000;'>$type</span></input><br/>"; } echo '</td></tr></table>'; ?> </div> I am having a problem getting these checkboxes repopulated. I think that a way to do this is to: Get the values out of the database in a array Compare the values the list of all possible values. Check the boxes of the values confirmed to be there. I didn't build the application so I need help to work through this problem. |