PHP - Trying To Get Form To Display Table Content On Drop Down
Name says it all. I have a form and 2 tables that are going to have to be linked with each other. Although what I'm trying to do now is very basic and I'm struggling haha Though this is my first php project
Basicly I got a form with a drop down menu, which I want to display the contents of my table (course) which the user then selects from and submits to another table (student) Here is my code for this part <?php Code: [Select] <?php $q = "SELECT cname FROM course "; $result = mysql_query($q); $course = mysql_fetch_array($result); ?> <div id="apdiv3"> <FORM action = "demo.php" method ="post"> <p>Course name:</p> <select name="cname"> <OPTION> <?php echo $course['cname']; ?> </option> </SELECT>?> It only displays 1 item from my course table. What am I doing wrong? And also please explain so I can learn from my mistakes Similar TutorialsAs a complete newbie to php and webdesigning i have a following problem.I would like to retrieve the data from database and display it in a drop down menu.Then i should allow the user to select the values from drop down list along with other details,in other words i have to embed the drop down output as the form input for the user and store the form data in another table.I am running a xampp server and i am using php 5.4 version.Please help.My code is as follows.In this case project_name is displayed as the drop down output.but how do i use the same drop down output as a input in the form. <html> <head></head> <body> <?php error_reporting(E_ALL ^ E_DEPRECATED); include 'connect.php' ; $tbl_name="projects"; $sql="SELECT project_name FROM $tbl_name "; $result=mysql_query($sql); if($result === FALSE) { die(mysql_error()); } ?> <form name="resources" action="hourssubmit.php" method="post" > <?php echo "<select name='project_name'>"; while ($row = mysql_fetch_array($result)) { echo "<option value='" . $row['project_name'] ."'>" . $row['project_name'] ."</option>"; } echo "</select>"; ?> </form> </body> </html> how i want to display data from database to look like this : <table width="633" height="224" border="1"> <tr bgcolor="#999900"> <td width="45">Bil</td> <td width="121">Course_name</td> <td width="83">session</td> <td width="83">start_date</td> <td width="83">end_date</td> <td width="83">notes</td> <td width="89">pre-req</td> </tr> <tr bgcolor="#6A7AEA"> <td rowspan="2">1.</td> <td rowspan="2" bgcolor="#6A7AEA">Math</td> <td>1st session </td> <td>1 jan 11 </td> <td>6 jan 11 </td> <td rowspan="2"> </td> <td rowspan="2"><image icon that will link to the oter site> </td> </tr> <tr> <td bgcolor="#6A7AEA">2nd session </td> <td bgcolor="#6A7AEA">8 jan 11 </td> <td bgcolor="#6A7AEA">15 jan 11 </td> </tr> <tr> <td bgcolor="#0066CC">2.</td> <td bgcolor="#0066CC">English</td> <td bgcolor="#0066CC">1st session </td> <td bgcolor="#0066CC">1 feb 11 </td> <td bgcolor="#0066CC">6 feb 11 </td> <td bgcolor="#0066CC"> </td> <td bgcolor="#0066CC"><image icon that will link to the oter site></td> </tr> <tr> <td rowspan="2" bgcolor="#6A7AEA">3.</td> <td rowspan="2" bgcolor="#6A7AEA">Science</td> <td height="29" bgcolor="#6A7AEA">1st session </td> <td bgcolor="#6A7AEA">8 march 11 </td> <td bgcolor="#6A7AEA">15 march 11 </td> <td rowspan="2" bgcolor="#6A7AEA"> </td> <td rowspan="2" bgcolor="#6A7AEA"><image icon that will link to the oter site></td> </tr> <tr> <td bgcolor="#6A7AEA">2nd session</td> <td bgcolor="#6A7AEA">16 march 11 </td> <td bgcolor="#6A7AEA">21 march 11 </td> </tr> </table> ** all the view data is called from database including the icon image thanks... Hi all I need to combine these two scripts: Firstly, the following decides which out of the following list is selected based on its value in the mySQL table: <select name="pack_choice"> <option value="Meters / Pack"<?php echo (($result['pack_choice']=="Meters / Pack") ? ' selected="selected"':'') ?>>Meters / Pack (m2)</option> <option value="m3"<?php echo (($result['pack_choice']=="m3") ? ' selected="selected"':'') ?>>Meters / Pack (m3)</option> <option value="Quantity"<?php echo (($result['pack_choice']=="Quantity") ? ' selected="selected"':'') ?>>Quantity</option> </select> Although this works OK, I need it also to show dynamic values like this: select name="category"> <?php $listCategories=mysql_query("SELECT * FROM `product_categories` ORDER BY id ASC"); while($categoryReturned=mysql_fetch_array($listCategories)) { echo "<option value=\"".$categoryReturned['name']."\">".$categoryReturned['name']."</option>"; } ?> </select> I'm not sure if this is possible? Many thanks for your help. Pete I have a drop down list which retrieves site name acronym and the url from the database. I need help in 2 things. 1.I do not want the url to be displayed in the drop down list. 2. When I hit submit I need to echo the sitename acronym as well as the url in a page called display.php. Here is my code so far: Code: [Select] <form action="display.php" method ="post"> <tr> <td>Category</td> <td> <select name="new_id"> <option value="">=============</option> <?php foreach($acronym as $key=>$value){ ?> <option value="<?php echo $value['site_id']; ?>"><?php echo $value['acronym']; ?></option> <option value="<?php echo $value['site_id']; ?>"><?php echo $value['url']; ?></option> <?php }?> </td> </tr> <input type="submit" name="submit" value="submit" /> </form> Slideshow programs created with Slideshow Maker. The html version works but opens in a new window. I want it to open in the content window same as all other programs. menu2.php (partial) <li> <a href="#">Slideshows</a> <ul> <li> <a href="index.php?page=slideshow_shed">Shed construction</a> </li> <li> <a href="content/pages/slideshow_shed.html">Shed Construction</a> </li> </ul> slideshow_shed.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Shed Pictures</title> </head> <body bgcolor="#FFFFFF"> <p> <p> <style type="text/css"> <!-- .style1 { color: #006633; font-weight: bold; } --> </style> <!-- saved from url=(0013)about:internet --> <table align="center" border="0" cellpadding=0 cellspacing=0> <tr> <td align="center">Shed Pictures</td> </tr> <tr><td align="center"><br /></td></tr> <tr> <td align="center"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="768" height="576" id="tech" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="slideshow_shed.swf" /> <param name="quality" value="high" /> <embed src="slideshow_shed.swf" quality="high" width="768" height="576" name="tech" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </td> </tr> <tr> <td align="center" ><br /> Created by <a href="http://www.flash-slideshow-maker.com/index.php?srcid=glc" target="_blank">Flash Slideshow Maker</a> </td> </tr> <tr> <td align="center" valign="middle" bgcolor="#FFCC99"><br /> <a href="http://www.flash-slideshow-maker.com/buynow.php?srcid=glc" target="_blank"><strong>Order the full version now to remove the software logo at the end of slideshow</strong></a> </td> </tr> </table> </body> </html> slideshow_shed.php <?php ?> <style type="text/css"> <!-- .style1 { color: #006633; font-weight: bold; } --> </style> <table align="center" border="0" cellpadding=0 cellspacing=0> <tr> <td align="center">Shed Pictures</td> </tr> <tr><td align="center"><br /></td></tr> <tr> <td align="center"> <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="768" height="576" id="tech" align="middle"> <param name="allowScriptAccess" value="sameDomain" /> <param name="movie" value="slideshow_shed.swf" /> <param name="quality" value="high" /> <embed src="slideshow_shed.swf" quality="high" width="768" height="576" name="tech" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object> </td> </tr> <tr> <td align="center" ><br /> Created by <a href="http://www.flash-slideshow-maker.com/index.php?srcid=glc" target="_blank">Flash Slideshow Maker</a> </td> </tr> <tr> <td align="center" valign="middle" bgcolor="#FFCC99"><br /> <a href="http://www.flash-slideshow-maker.com/buynow.php?srcid=glc" target="_blank"><strong>Order the full version now to remove the software logo at the end of slideshow</strong></a> </td> </tr> </table> I don't get any errors, just the title "Shed Pictures" displays. Most of the websites I have built have not been large and not dynamic in nature, but I need to make one now with a boatload of content on it. and I’m needing a little resource help where I can research something. I’m sure all developers do this, and I know I need a massive database or 2 and the PHP knowledge I already have, but I’m just looking for a little guidance about how to do this the easiest way. It may actually sound like a stupid question and I might be over-thinking a bit. So… Lets say I have 500 articles that I want to make available to a site visitor and give them the option to choose what they want to look at through nav menus and submenus. I want the same page to display to the user, regardless of what article is chosen. how does PHP play a part in that? Would I be right by saying the following? If the home page had this content on it: This website is a course in PHP coding. <a href="courseTemplate.php" target="_blank">Click here</a> to view course #1. and I wanted all the course content to be displayed through the use of the “courseTemplate.php” file, how simple is that? I would assume that these types of things would be the results and the techniques to accomplish the goal, right? => a resulting URL that looks like this: www.site.com/courseTemplate.php?id=1 => storing all the text of the course material in one single field of a DB record. NOT storing the layout-oriented code (HTML, etc.) and echoing it out with the rest of the text. => making use of the GET() function somehow to pull the course’s text content out of the database. Can someone show me a website that demonstrates this? I don’t think this is very difficult, and I’m sure there are web resources available that show how this is done. I’m almost sure that most news agency websites do this, and I know for a fact that most forum software has this template technique written into it, regardless if SEO is included or not. Sorry for the basic nature of this question. I know some of my previous posts have been such where I’ve asked much more difficult questions than this. I have seen youtube tutorials on issues similar to this, but nothing pulled up by google really shows this in a very simplistic nature. thanks. I've used a little PHP but I am not great. Is there any way to take information from a html page written in basic text and have it dynamically displayed. The content I want is found he http://www.kitco.com/texten/texten.html I want to take the information from the following chart - only Metal and Ask and create a ticker. New York Spot Price MARKET IS OPEN Will close in 2 hour 24 minutes ---------------------------------------------------------------------- Metals Bid Ask Change Low High ---------------------------------------------------------------------- Gold 1822.80 1823.80 -12.30 -0.67% 1810.70 1840.90 Silver 41.45 41.55 +0.10 +0.24% 41.08 42.15 Platinum 1844.00 1852.00 -7.00 -0.38% 1826.00 1861.00 Palladium 783.00 788.00 +10.00 +1.29% 775.00 794.00 ---------------------------------------------------------------------- So basically I would just take the word: Gold - $1823.80 Silver - $41.55 Platinum $1852.00 Palladium - $788.00 Can someone help me through this or point me in a direction where I can read more about accomplishing this? I've been searching google for articles but still haven't found what I'm looking for. nofx1728 Hi folks, I am in the middle of creating a CMS as a project. It's going pretty well so far but I am stuck and hoping to get some guidance. When loading the main website, I want the contents from "Home" in the database to display unless a menu item is clicked. Here is what I have so far: <?php include_once('includes/header.php'); require_once('admin/includes/config.php'); ?> <div class="hero-wrap" style="background-image: url('images/uluru.jpg');" data-stellar-background-ratio="0.5"> <div class="overlay"></div> <div class="container"> <div class="row no-gutters slider-text justify-content-start align-items-center"> <div class="col-lg-6 col-md-6 ftco-animate d-flex align-items-end"> <div class="text"> <h1 class="mb-4">Coaches For Hire <span>Book Now!</span></h1> <p style="font-size: 18px;">The local Anangu, the Pitjantjatjara people, call the landmark Uluṟu (Pitjantjatjara [ʊlʊɻʊ]). This word is a proper noun, with no further particular meaning in the Pitjantjatjara dialect, although it is used as a local family name by the senior Traditional Owners of Uluru.</p> <a href="https://www.youtube.com/watch?v=biuYA54nb7Y" class="icon-wrap popup-vimeo d-flex align-items-center mt-4"> <div class="icon d-flex align-items-center justify-content-center"> <span class="ion-ios-play"></span> </div> <div class="heading-title ml-5"> <span>Learn more about Uluru</span> </div> </a> </div> </div> <div class="col-lg-2 col"></div> <div class="col-lg-4 col-md-6 mt-0 mt-md-5 d-flex"> <form action="#" class="request-form ftco-animate"> <h2>Get A Quote</h2> <div id="searchBoxContainer" class="form-group"> <label for="searchBox" class="label">Pick-Up Location</label> <input class="form-control" type="text" id="searchBox" placeholder="Start Typing..." /> </div> <div id="searchBoxContainerAlt" class="form-group"> <label for="searchBoxAlt" class="label">Drop-Off Location</label> <input type="text" class="form-control" id="searchBoxAlt" placeholder="Start Typing..." /> </div> <div class="d-flex"> <div class="form-group mr-2"> <label for="" class="label">Departure Date</label> <input type="text" class="form-control" id="book_pick_date" placeholder="Date"> </div> <div class="form-group ml-2"> <label for="" class="label">Return Date</label> <input type="text" class="form-control" id="book_off_date" placeholder="Date"> </div> </div> <div class="d-flex"> <div class="form-group mr-2"> <label for="" class="label">Pick-Up Time</label> <input type="text" class="form-control" id="time_pick" placeholder="Time"> </div> <div class="form-group ml-2"> <label for"" class="label">Passenger Numbers</label> <input type="number" class="form-control" placeholder="Amount" /> </div> </div> <div class="form-group"> <input type="submit" value="Request Quote" class="btn btn-primary py-3 px-4"> </div> </form> </div> </div> </div> </div> <script type="text/javascript" src="https://www.bing.com/api/maps/mapcontrol?key=AqIY0ivSCCdBIe3-EKGuox9cwBFw2wWRWIErZi1iy57EfD67PoiSra9wl_wu48de&callback=bingMapsReady" async defer></script> <?php $id = $_GET['id']; $sql = "SELECT * FROM pages WHERE id = $id"; $result = $con->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_array()) { ?> <!-- HOW IT WORKS --> <section class="ftco-section ftco-no-pt ftco-no-pb"> <div class="container"> <div class="row no-gutters"> <div class="col-md-12 wrap-about py-md-5 ftco-animate"> <div class="heading-section mb-5 pl-md-5"> <span class="subheading"><?php echo $row['description']; ?> </span> <h2 class="heading"><?php echo $row['name']; ?></h2> <?php echo $row['body']; ?> </div> </div> </div> </div> </section> <?php } } ?> <!-- FOOTER --> <?php include_once('includes/footer.php'); ?> I hope you can help and that I am making sense. Cheers, Dan Edited January 9 by DanEthicalHi everyone, On my website i have a drop down box on the account information page that has a list of countries. In the example below, im using the php to do 2 things, 1: if the user changes the country and clicks submit but an error is found on the page, rather than revert back to the original country it stays as the newly selected one. 2: if the user does not change the country, the country from the database is simple displayed. As you can see below it is taking up quite a bit of code. I was wondering if anybody has any ideas how i can make this smaller? <select name="country"> <option value="select" selected>Select...</option> <option value="Afganistan" <?php if ($submit) { if ($country == "Afganistan"){ echo "selected";}} else {if ($row['country'] == "Afganistan") {echo "selected";}} ?>>Afghanistan</option> <option value="Albania" <?php if ($submit) {if ($country == "Albania"){echo "selected";}} else {if ($row['country'] == "Albania") {echo "selected";}} ?>>Albania</option> <option value="Algeria" <?php if ($submit) {if ($country == "Algeria"){echo "selected";}} else {if ($row['country'] == "Algeria") {echo "selected";}} ?>>Algeria</option> <option value="American Samoa" <?php if ($submit) {if ($country == "American Samoa"){echo "selected";}} else {if ($row['country'] == "American Samoa") {echo "selected";}} ?>>American Samoa</option> <option value="Andorra"<?php if ($submit) {if ($country == "Andorra"){echo "selected";}} else {if ($row['country'] == "Andorra") {echo "selected";}} ?>>Andorra</option> <option value="Angola"<?php if ($submit) {if ($country == "Angola"){echo "selected";}} else {if ($row['country'] == "Angola") {echo "selected";}} ?>>Angola</option> Thanks Stumped! I have a client who has a form where they upload files to their server: title, two password fields, and the file
They have been unable to upload anything over 10m
Small (under 10mb) files work.
Larger doesn’t
I’ve tracked it down, I think, that the processing page appears to be dropping the form values when the file takes a bit to upload.
I echo’ed the values that are grabbed from the form, and they return empty strings if it takes a while for the file to upload (a large file) - they pass fine if the file is smaller.
I think I've got the php info set correctly, but cannot for the life of me figure out how to adjust the timing out issue, or even where to troubleshoot.
Here's my phpinfo:
Max Requests
Per Child: 750 - Keep Alive: off - Max Per Connection: 100
Timeouts
Connection: 120 - Keep-Alive: 5
Directive
Local Value
Master Value
allow_call_time_pass_reference
Off
Off
allow_url_fopen
On
On
allow_url_include
Off
Off
always_populate_raw_post_data
Off
Off
arg_separator.input
&
&
arg_separator.output
&
&
asp_tags
Off
Off
auto_append_file
no value
no value
auto_globals_jit
On
On
auto_prepend_file
no value
no value
browscap
/etc/browscap.ini
/etc/browscap.ini
default_charset
no value
no value
default_mimetype
text/html
text/html
define_syslog_variables
Off
Off
disable_classes
no value
no value
disable_functions
leak,posix_getpwuid,posix_getpwnam,posix_getgrid,posix_getgrnam,posix_getgroups
leak,posix_getpwuid,posix_getpwnam,posix_getgrid,posix_getgrnam,posix_getgroups
display_errors
Off
Off
display_startup_errors
Off
Off
doc_root
no value
no value
docref_ext
no value
no value
docref_root
no value
no value
enable_dl
Off
Off
error_append_string
no value
no value
error_log
/mnt/Target01/337846/945285/www.dermerrealestate.com/logs/php_errors.log
no value
error_prepend_string
no value
no value
error_reporting
30711
30711
exit_on_timeout
Off
Off
expose_php
Off
Off
extension_dir
/usr/lib64/php/modules
/usr/lib64/php/modules
file_uploads
On
On
highlight.bg
#FFFFFF
#FFFFFF
highlight.comment
#FF8000
#FF8000
highlight.default
#0000BB
#0000BB
highlight.html
#000000
#000000
highlight.keyword
#007700
#007700
highlight.string
#DD0000
#DD0000
html_errors
On
On
ignore_repeated_errors
Off
Off
ignore_repeated_source
Off
Off
ignore_user_abort
Off
Off
implicit_flush
Off
Off
include_path
.:/usr/share/pear:/usr/share/php
.:/usr/share/pear:/usr/share/php
log_errors
On
On
log_errors_max_len
1024
1024
magic_quotes_gpc
On
On
magic_quotes_runtime
Off
Off
magic_quotes_sybase
Off
Off
mail.add_x_header
On
On
mail.force_extra_parameters
no value
no value
mail.log
no value
no value
max_execution_time
30
30
max_file_uploads
20
20
max_input_nesting_level
64
64
max_input_time
60
60
max_input_vars
1000
1000
memory_limit
128M
128M
open_basedir
no value
no value
output_buffering
no value
no value
output_handler
no value
no value
post_max_size
8M
8M
precision
14
14
realpath_cache_size
4M
4M
realpath_cache_ttl
120
120
register_argc_argv
On
On
register_globals
Off
Off
register_long_arrays
On
On
report_memleaks
On
On
report_zend_debug
On
On
request_order
no value
no value
safe_mode
Off
Off
safe_mode_exec_dir
no value
no value
safe_mode_gid
Off
Off
safe_mode_include_dir
no value
no value
sendmail_from
no value
no value
sendmail_path
/usr/sbin/sendmail -t -i
/usr/sbin/sendmail -t -i
serialize_precision
100
100
short_open_tag
On
On
SMTP
localhost
localhost
smtp_port
25
25
sql.safe_mode
Off
Off
track_errors
Off
Off
unserialize_callback_func
no value
no value
upload_max_filesize
8M
8M
upload_tmp_dir
/tmp
/tmp
user_dir
no value
no value
user_ini.cache_ttl
300
300
user_ini.filename
.user.ini
.user.ini
variables_order
EGPCS
EGPCS
xmlrpc_error_number
0
0
xmlrpc_errors
Off
Off
y2k_compliance
On
On
zend.enable_gc
On
On
Hello my problem here is to have a drop down menu which gathers usernames from the database. Then with a click of a button the information for that specific user selected is shown. I'm close code wise but right now it's just showing me all users. I'm displaying the info in text box's to allow an admin to change the info.
<form action="edit.php" method="post"> <select name="username" id="username"> <?php // Connects to your Database $con=mysqli_connect('localhost', 'root', ''); /* check connection */ if (mysqli_connect_errno($con)) { trigger_error('Database connection failed: ' . mysqli_connect_error(), E_USER_ERROR); } $query = "SELECT `username` FROM `bencobricks` . `users`"; $result = mysqli_query($con, $query) or trigger_error("Query Failed! SQL: $query - Error: ". mysqli_error($con), E_USER_ERROR); if($result) { while($row = mysqli_fetch_assoc($result)) { //printf ("%s\n %s\n ", echo "<label for='username'>Username: </label> <option value='$row[username]'>$row[username] </option><br/>"; echo "<br/><br/> "; } } mysqli_close($con); ?> </select> <br /> <input name="send" id="send" type="submit" value="Edit User" /> </form>Then in the edit.php file i have this code: <?php // Connects to your Database $con=mysqli_connect('localhost', 'root', ''); /* check connection */ if (mysqli_connect_errno($con)) { trigger_error('Database connection failed: ' . mysqli_connect_error(), E_USER_ERROR); } if (isset($_POST['send'])) { $username = $_POST['username']; $query = "SELECT * FROM `bencobricks` . `users` "; $result = mysqli_query($con, $query) or trigger_error("Query Failed! SQL: $query - Error: ". mysqli_error($con), E_USER_ERROR); // Print the result if($result) { while ($row = mysqli_fetch_assoc($result)) { // $query = "SELECT * FROM `bencobricks` . `users` WHERE `username` = username = $row[username]"; printf ("%s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n %s\n", "<label for='username'>Username: </label> <input type='text' name='username' value='$row[username]'>" . "</input><br/>", "<label for='email'>Email: </label> <input type='text' name='email' value='$row[email]'>" . "</input><br/>", "<label for='membership'>Membership: </label> <input type='text' name='membership' value='$row[membership]'>" . "</input><br/>", "<label for='firstName'>First name: </label> <input type='text' name='firstName' value='$row[firstName]'>" . "</input><br/>", "<label for='lastName'>Last name: </label> <input type='text' name='lastName' value='$row[lastName]'>" . "</input><br/>", "<label for='gender'>Gender: </label> <input type='text' name='gender' value='$row[gender]'>" . "</input><br/>", "<label for='dateOfBirth'>Birthdate: </label> <input type='text' name='dateOfBirth' value='$row[dateOfBirth]'>" . "</input><br/>", "<label for='date'>Date: </label> <input type='text' name='date' value='$row[date]'>" . "</input><br/>", "<label for='sets'>Sets: </label> <input type='text' name='sets' value='$row[sets]'>" . "</input><br/>", "<label for='checkbox'>Checkbox: </label> <input type='text' name='checkbox' value='$row[checkbox]'>" . "</input><br/>", "<label for='admin'>Admin? </label> <input type='text' name='admin' value='$row[adminFlag]'>" . "</input><BR>", "<br/><br/> "); } } } mysqli_close($con); ?>Any help is greatly appreciated. Hi i am trying to change the query to sort by desc or asc I am using the switch method but the form is not calling the switch statment can someone help me out please? this is the swicth script Code: [Select] switch ($sortby) { case "ASC": $args = array( 's' => $_GET['s'], 'post_type' => 'deals', 'orderby' => 'title', 'order' => 'ASC', 'paged' => get_query_var('paged') ); break; case "DESC": $args = array( 's' => $_GET['s'], 'post_type' => 'deals', 'orderby' => 'title', 'order' => 'DESC', 'paged' => get_query_var('paged') ); break; }This is the form Code: [Select] <form name="myForm"> <select id="sortby" > <option value="ASC">ASC</option> <option value="DESC">DESC</option> </select> </form> I intend to use a onchange so that when depending on the option they select it will change the order? Hello, I have coded a contact form in PHP and I want to know, if according to you, it is secure! I am new in PHP, so I want some feedback from you. Moreover, I have also two problems based on the contact form. It is a bit complicated to explain, thus, I will break each of my problem one by one. FIRST:The first thing I want to know, is if my contact form secure according to you: The HTML with the PHP codes: Code: [Select] <?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { //Assigning variables to elements $first = htmlentities($_POST['first']); $last = htmlentities($_POST['last']); $sub = htmlentities($_POST['subject']); $email = htmlentities($_POST['email']); $web = htmlentities($_POST['website']); $heard = htmlentities($_POST['heard']); $comment = htmlentities($_POST['message']); $cap = htmlentities($_POST['captcha']); //Declaring the email address with body content $to = 'alithebestofall2010@gmail.com'; $body ="First name: '$first' \n\n Last name: '$last' \n\n Subject: '$sub' \n\n Email: '$email' \n\n Website: '$web' \n\n Heard from us: '$heard' \n\n Comments: '$comment'"; //Validate the forms if (empty($first) || empty($last) || empty($sub) || empty($email) || empty($comment) || empty($cap)) { echo '<p class="error">Required fields must be filled!</p>'; header ('refresh= 3; url= index.php'); return false; } elseif (filter_var($first, FILTER_VALIDATE_INT) || filter_var($last, FILTER_VALIDATE_INT)) { echo '<p class="error">You cannot enter a number as either the first or last name!</p>'; return false; } elseif (!filter_var($email, FILTER_VALIDATE_EMAIL)) { echo '<p class="error">Incorrect email address!</p>'; return false; } elseif (!($cap === '12')){ echo '<p class="error">Invalid captcha, try again!</p>'; return false; } else { mail ($to, $sub, $body); echo '<p class="success">Thank you for contacting us!</p>'; } } ?> <form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post"> <p>Your first name: <span class="required">*</span></p> <p><input type="text" name="first" size="40" placeholder="Ex: Paul"/></p> <p>Your last name: <span class="required">*</span></p> <p><input type="text" name="last" size="40" placeholder="Ex: Smith"/></p> <p>Subject: <span class="required">*</span></p> <p><input type="text" name="subject" size="40" placeholder="Ex: Contact"/></p> <p>Your email address: <span class="required">*</span></p> <p><input type="text" name="email" size="40" placeholder="Ex: example@xxx.com"/></p> <p>Website:</p> <p><input type="text" name="website" size="40" placeholder="Ex: http//:google.com"/></p> <p>Where you have heard us?: <span class="required">*</span></p> <p><select name="heard"> <option>Internet</option> <option>Newspapers</option> <option>Friends or relatives</option> <option>Others</option> </select></p> <p>Your message: <span class="required">*</span></p> <p><textarea cols="75" rows="20" name="message"></textarea></p> <p>Are you human? Sum this please: 5 + 7 = ?: <span class="required">*</span></p></p> <p><input type="text" name="captcha" size="10"/></p> <p><input type="submit" name="submit" value="Send" class="button"/> <input type="reset" value="Reset" class="button"/></p> </form> SECOND PROBLEM:If a user has made a mistake, he gets the error message so that he can correct! However, when a mistake in the form occurs, all the data the user has entered are disappeared! I want the data to keep appearing so that the user does not start over again to fill the form. THIRD: When the erro message is displayed to notify the user that he made a mistake when submitting the form, the message is displaying on the top of the page. I want it to appear below each respective field. How to do that? In JQuery it is simple, but in PHP, I am confusing! Hi, I am building function to convert the db table to an XML file. But I want to retrieve the root node value from the FIRST row in that db table before I build a for loop to traverse that db table. Let's say I have this table NodeInfo: node_Id source target ====== ===== ===== 1 email to 2 to toFirstName pseudocode for what I want: 1) store root (the source field of table NodeInfo 2)for each entry in table NodeInfo, do: build XML END FOR-EACH Any help much appreciated! Code: [Select] $q = mysqli_query($mysqli, "DROP TABLE IF EXIST 'airline_survey'"); if($q){echo "deleted the table airline_survey....<br>";} else{echo "damm... ".mysqli_error($mysqli);} $mysqli is my connection and it works I had no trouble creating the table but I decided to add these few lines in front of the code to create the table and I get this error. damm...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 'EXIST 'airline_survey'' at line 1 I gotta believe this is really simple but it's got me stumped. Hi, I'm trying to drop a table form a database using the table name as a variable. This variable is set within a session. I am using a form where you input the table name, then the DROP TABLE procedure is executed in the next page. I know that the variable gets passed because it prints the table name variable out when I "echo". The execution is simple (code found in deletetable.php) $temp = $_POST['temp']; $query = "DROP TABLE $temp"; if(mysql_query($query)){ echo "<h1 style='color:green;'>Table $temp deleted</h1>";} else{ echo "<h1 style='color:red;'>Deletion of table '$temp' failed!</h1>";} Here's my code for the two pages: delete_table.php <?php include("includes/header.html"); session_start(); $hostname = $_SESSION['hostname']; $user = $_SESSION['user']; $passwd = $_SESSION['passwd']; $database = $_SESSION['database']; $tblname = $_SESSION['table']; $conn = mysql_connect($hostname, $user, $passwd, $database); /*if(! $conn ) { die('Could not connect: ' . mysql_error()); }*/ ?> <div id="container"> <div id="header">Create DB</div> <div id="breadcrumbs"> <?php function check_port($port) { $conn = @fsockopen("127.0.0.1", $port, $errno, $errstr, 0.2); if ($conn) { fclose($conn); return true; } } function server_report() { $report = array(); $svcs = array('3306'=>'MySQL'); foreach ($svcs as $port=>$service) { $report[$service] = check_port($port); } return $report; } $report = server_report(); ?> <div id="server"><p>Server is <?php echo $report['MySQL'] ? "running" : "offline"; ?></p></div> <?php if(!$_SESSION['hostname']){ echo "<font color='red'>Not connected to server!</font>"; } else { echo "<font color='green'>Server: ".$_SESSION['hostname']."</font>"; } if(!$_SESSION['database']){ echo ""; }else{ echo "<br><font color='green'>Database: ".$_SESSION['database']."</font>"; } ?> </div> <div id="nav"> <p><a href="#" onclick="javascript:window.open('connect_db.php','_self');"><img src="server_conn_ico.png" align="left" />Server Connection</a></p> <p><a href="databases.php"><img src="databases_ico.png" align="left" />View Database</a></p> <p><a href="create_db.php"><img src="server_folder_ico.png" align="left" />Create Database</a></p> <p><a href="drop_db.php"><img src="drop_ico.png" align="left" />Drop Database</a></p> <p><a href="create_table.php"><img src="status_ico.png" align="left" />Add Table</a></p> <p><a href="add_fields.php"><img src="server_ico.png" align="left" />Add Fields</a></p> <p class="active"><a href="delete_table.php"><img src="status_delete_ico.png" align="left" />Delete Table</a></p> <p><a href="view_tables.php"><img src="user_admin_ico.png" align="left" />View Tables</a></p> <p><a href="view_data.php"><img src="user_admin_ico.png" align="left" />View Table Data</a></p> <p><a href="http://localhost/phpmyadmin/" target="_blank"><img src="phpmyadmin_ico.png" align="left" />phpMyAdmin</a></p> <p><a href="connect_info.php"><img src="health_ico.png" align="left" />System Info</a></p> <p><a href="error_log.php"><img src="logs_ico.png" align="left" />Server Log</a></p> <p><a href="bug_report.php"><img src="bugs-icon.png" align="left" />Bug Reports</a></p> </div> <div id="controls"><a href="javascript:self.close()"><img src="controls.png" /></a></div> <div id="main"> <div id="content"> <!--<h1>Delete Database Table</h1>--> <?php if(empty($database)) { echo "<p>You must be connected to a database in order to delete a table.</p>"; }else{ //echo 'Connected successfully to \''.$database.'\''; // Check tables $sql = "SHOW TABLES FROM $database"; $result = mysql_query($sql); if (mysql_num_rows($result) > 0) { echo "<p style='text-align:left;padding-left:24px;'>Available tables:</p>\n"; echo "<pre style='text-align:left;padding-left:24px;font-size:1.2em;'>\n"; while ($row = mysql_fetch_row($result)) { echo "{$row[0]}\n"; } echo "</pre>\n"; } ?> <form action="deletetable.php" method="post"> Enter table you'd like to delete from '<?php echo $database; ?>' database: <input name="temp" type="text" /><br/> <input name="Submit" type="submit" value=" Delete Table " /> <input type='button' value=' Cancel ' onclick="javascript:window.location='connect_db.php';"></p> </form> <?php } include("includes/footer.html"); ?> Executing file deletetable.php: <?php include("includes/header.html"); session_start(); $hostname = $_SESSION['hostname']; $user = $_SESSION['user']; $passwd = $_SESSION['passwd']; $database = $_SESSION['database']; //$tblname = $_SESSION['table']; $conn = mysql_connect($hostname, $user, $passwd, $database); ?> <div id="container"> <div id="header">Create DB</div> <div id="breadcrumbs"> <?php function check_port($port) { $conn = @fsockopen("127.0.0.1", $port, $errno, $errstr, 0.2); if ($conn) { fclose($conn); return true; } } function server_report() { $report = array(); $svcs = array('3306'=>'MySQL'); foreach ($svcs as $port=>$service) { $report[$service] = check_port($port); } return $report; } $report = server_report(); ?> <div id="server"><p>Server is <?php echo $report['MySQL'] ? "running" : "offline"; ?></p></div> <?php if(!$_SESSION['hostname']){ echo "<font color='red'>Not connected to server!</font>"; } else { echo "<font color='green'>Server: ".$_SESSION['hostname']."</font>"; } if(!$_SESSION['database']){ echo ""; }else{ echo "<br><font color='green'>Database: ".$_SESSION['database']."</font>"; } ?> </div> <div id="nav"> <p><a href="#" onclick="javascript:window.open('connect_db.php','_self');"><img src="server_conn_ico.png" align="left" />Server Connection</a></p> <p><a href="databases.php"><img src="databases_ico.png" align="left" />View Database</a></p> <p><a href="create_db.php"><img src="server_folder_ico.png" align="left" />Create Database</a></p> <p><a href="drop_db.php"><img src="drop_ico.png" align="left" />Drop Database</a></p> <p><a href="create_table.php"><img src="status_ico.png" align="left" />Add Table</a></p> <p><a href="add_fields.php"><img src="server_ico.png" align="left" />Add Fields</a></p> <p class="active"><a href="delete_table.php"><img src="status_delete_ico.png" align="left" />Delete Table</a></p> <p><a href="view_tables.php"><img src="user_admin_ico.png" align="left" />View Tables</a></p> <p><a href="view_data.php"><img src="user_admin_ico.png" align="left" />View Table Data</a></p> <p><a href="http://localhost/phpmyadmin/" target="_blank"><img src="phpmyadmin_ico.png" align="left" />phpMyAdmin</a></p> <p><a href="connect_info.php"><img src="health_ico.png" align="left" />System Info</a></p> <p><a href="error_log.php"><img src="logs_ico.png" align="left" />Server Log</a></p> <p><a href="bug_report.php"><img src="bugs-icon.png" align="left" />Bug Reports</a></p> </div> <div id="controls"><a href="javascript:self.close()"><img src="controls.png" /></a></div> <div id="main"> <div id="content"> <?php $temp = $_POST['temp']; $query = "DROP TABLE $temp"; if(mysql_query($query)){ echo "<h1 style='color:green;'>Table $temp deleted</h1>";} else{ echo "<h1 style='color:red;'>Deletion of table '$temp' failed!</h1>";} include("includes/footer.html"); ?> Your help is greatly appreciated!! Hey guys, I made in php an sql droplist. But I need some help. I want it to work like this. When I select something from the list and click Add To Cart, that also the product gets send to the cart and not only the quantity. you can check it out here : http://fhcs.be/cart-demo2/index.php I also added my index.php as an attachment Greets Hi all, 1) I realised after applying php's codes, the contents in 'panel 2' doesn't stay within 'panel 2', apparently the contents went outside of 'panel 2 <div>'. Attached is the picture example. Is there anything amiss which I have done? 2) Another thing, I realised the <td> is very far apart from the next <td>, example... Code: [Select] if (!empty($row1['uni2'])) { echo '<tr><td class="label">Faculty or Course:</td><td>' . $row1['uni2'] . '</td></tr>'; } <td class="label">Faculty or Course:</td> is apparently very far apart from <td>' . $row1['uni2'] . '</td> As you can see it in the attachment. How do i close up the wide gap? Thanks Code: [Select] echo '<div id="panel2">'; /***University***/ echo '<table>'; if (!empty($row1['uni1'])) { echo '<br/><tr><td class="row_header">' . $row1['uni1'] . '</td></tr>'; if (!empty($row1['uni2'])) { echo '<tr><td class="label">Faculty or Course:</td><td>' . $row1['uni2'] . '</td></tr>'; } if (!empty($row1['uni3'])) { echo '<tr><td class="label">Results:</td><td>' . $row1['uni3'] . '</td></tr>'; } } echo '</table>'; echo '</div>'; //End of Panel 2 Hi, I wonder if I somebody can help me I have three drop down lists which are populated from data thats stored in my sql database. I also have a table which is echoed from the database all on the same page. What i want to do is allow users to select values in the drop down lists which will then echo different results below in the table. Is this possible. So on page load it will show all of the info in the html table. Then when the user changes the drop downs and clicks submit it will change the query to something SELECT dropdown1 value FROM users where Dropdown2 = 1 AND Dropdown3 = 2 etc. Is this possible to display this information on the same page using the dropdown list or does it need to load a different page as the client side is trying to edit a server side script? If its possible please can someone give me an example. Thanks in advance Edd I am wanting HTML to render within a table and sourcing the data from another file. In an attempt to do this, I tried: Code: [Select] <TABLE class="main"> <TR> <TD> <?php readfile('./1/index.html'); ?> </TD> </TR> </TABLE> This does not work and I am wondering if anyone knows how it can be done - or even if it can be done? |