PHP - Drop Down List Not Displaying Info Online Only On Localhost
Hi, I am using this code to display the info in mysql database to dropdown list, it is working good on the localhost, when I upload everything the form is still working fine, but the drop down list are not displaying anything!!
What could be the problem? * I did upload all the tables also Code: [Select] <?php $query="SELECT ID, nationality FROM nationalities"; $result = mysql_query ($query); echo "<select name=first_nationality_father value=''></option>"; echo "<option value=''>-- Choose one --</option>"; while($nt=mysql_fetch_array($result)){ echo "<option value=$nt[nationality]>$nt[nationality]</option>"; } echo "</select>"; ?> Similar Tutorials I have create a working site at localhost but when I upload it to webhost, it's not working, all link broken.
This is the site.
this is the directory :
The index.php content is :
<?php header('location:home.html'); ?>and the .htaccess content is : RewriteEngine on RewriteRule ^home.html$ main/home.php?main=home [L] RewriteRule ^penyakit.html$ main/home.php?main=penyakit [L] RewriteRule ^review-(.*)\.html$ main/home.php?main=detilgejala&id=$1 [L] RewriteRule ^solusi.html$ main/home.php?main=solusi [L] RewriteRule ^proses$ main/home.php?main=prosessolusi [L] RewriteRule ^bukutamu.html$ main/home.php?main=bukutamu [L] RewriteRule ^send-contact$ main/main_bukutamu/proses_bukutamu.php [L] RewriteRule ^about.html$ main/home.php?main=about [L] RewriteRule ^ensiklopedia.html$ main/home.php?main=ensiklopedia [L] Options All -indexesThis config work in localhost. Thanks for your attention and respond, it help me so much and sorry for the topic's title can't edited it. Edited by havide, 31 October 2014 - 12:35 PM. This is a multiplication test for students to take and when they finish they click the score button. after they click the score button it tells them what their score is, with the opportunity to take it again. What I am trying to do is make this able to keep the recent score and just post the next score. Right now my app just gives the first score and then when I take the test again it just refreshes and gives the new score. I want it to play the new score under the old score. I can't seem to figure out how to do this. If someone could help point me in the right direction. Would appreciate the help. Here is my code for my app.... Code: [Select] <?php require_once('database.php'); define ('ROWS', 3); define ('COLS', 3); define ('MAX_NUMBER', 12); date_default_timezone_set('America/New_York'); if (isset($_POST['btn_score'])) { $result_name= $_POST['result_name']; $correct = 0; //print_r ($_POST); $time1 = $_POST['ts']; $time1_object = new DateTime($time1); $now = new DateTime(); $time_span = $now->diff($time1_object); $minutes = $time_span->format('%i'); $seconds = $time_span->format('%s'); $seconds+= $minutes * 60; echo "It took $seconds seconds to complete the test<hr />"; foreach ($_POST as $problem => $answer) { if ($problem <> "btn_score" && $problem <> "ts" && $problem <> "result_name") { //echo "$problem -- $answer <br />"; $problem = explode('_', $problem); $num1 = $problem[2]; $num2 = $problem[3]; $right = $num1 * $num2; if ($answer != $right) { echo "$num1 * $num2 = $answer , The right answer is $right<br />"; }else { $correct = $correct + 1; } } } $result_score= 0; $result_score= ($correct / 9) * 100; echo "your score is <br/>$result_score<br/>"; } $sql = "INSERT INTO results (result_name, result_score, result_date_time) VALUES ('$result_name','$result_score', NOW());"; ?> <h1>Multiplication Test</h1> <form name="lab5" method="post" action="lab5b.php"> <?php $now = new DateTime(); //echo $now->format('Y-m-d H:i:s'); echo "<input type='hidden' name='ts' value='" . $now->format('Y-m-d H:i:s') . "'>"; ?> <table border="1" cellspacing="5" cellpadding="5"> <?php $no_of_problems = 0; for ($row=0; $row<ROWS; $row++) { echo "<tr>"; for ($col=0; $col<COLS; $col++) { $num1 = mt_rand(1,MAX_NUMBER); $num2 = mt_rand(1,MAX_NUMBER); echo "<td>$num1 * $num2 </td>"; echo "<td><input type='text' size='2' name=${no_of_problems}_mult_${num1}_${num2}></td>"; $no_of_problems++; } echo "</tr>"; } $colspan = 2 * COLS; echo "<tr><td colspan=$colspan align='right'><input type='submit' value='Score' name='btn_score'></td></tr>"; ?> Well this is pretty much the first time I'm attempting something new without a tutorial aiding me ( I know your gonna think I probably should have used 1 when checking my code ) Honestly my brain is fried, but I have a deadline for tomorrow. Basicly I'm sending an email upon registration ( email sends fine ) I made it so the email display the students name and course. However in my registration a student can select contact y or n, which determines whether the student wants to be contacted by other students. So when sending an email to a student who selected n for contact, is should only display the students name and course (sname, fname, cname). However, for a student who selected y for contact, it should display the name and course aswell of a list display the sname,fname and email of all the other students in my student table who selected y in their contact_flag field. Here is my misguided code: Code: [Select] <?php function sendmail(){ $cname = mysql_real_escape_string($_POST['cname']); $sname = mysql_real_escape_string($_POST['sname']); $fname = mysql_real_escape_string($_POST['fname']); $contact = mysql_real_escape_string($_POST['contact']); $Name = "Student Course Registration"; //senders name $email = "goldie@telkomsa.net"; //senders e-mail adress $recipient = ($_POST['email']); //recipient $mail_body = "Congratulations $fname $sname. You have successfully registered for the following course: $cname "; //mail body $subject = "Course registration successful!"; //subject $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields if ($contact=='y'){ $query = "SELECT sname,fname,email FROM student WHERE $contact = ['contact_flag'] "; $run = mysql_query($query) or die(mysql_error()); $found = mysql_fetch_array($run); while ($found = mysql_fetch_array($run)) $contactemail=$person['email']; $contactsname=$person['sname']; $contactfname=$person['fname']; $mail_body2 = "Congratulations $fname $sname. You have successfully registered for the following course: $cname. Here is a list of all the students who you may be in contact with: $contactsname, $contactfname, $contactemail"; //mail body for contact flag { mail($recipient, $subject, $mail_body2, $header); } } else { mail($recipient, $subject, $mail_body, $header); } } ?> I am not receiving any errors from it, and I'm receiving an email which displays $mail_body instead of $mail_body2 which is my else statement. Please, help would be appreciate. Thanks in advance. I am trying to have the data from my database display on a webpage the problem I am having is two fold one the 1. picture number is not displaying in order 2. how do I get the birth date to display in D- M - Y on webpage the output displays = 2007-05-11 <?php$con = mysql_connect("localhost","","");if (!$con) { die('Could not connect: ' . mysql_error()); }mysql_select_db("sacredfa_sacred", $con);$query = "SELECT picture_number, first_name, middle_name, first_family_name, second_family_name, birthdate, gender FROM child_info"; $result = mysql_query($query); if(!$result) { echo "There was a problem getting the data"; } else if(!$result) { echo "There were no results"; } else { echo "<b><center>Children to be sponsored</center></b><br><br>\n"; while($row = mysql_fetch_assoc($result)) { echo "<table border='1'><tr><th>Picture Number</th><th>First Name</th><th>Middle Name</th><th>First Family Name</th><th>Second Family Name</th><th>Birthdate</th><th>Gender</th></tr>";while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['picture_number'] . "</td>"; echo "<td>" . $row['first_name'] . "</td>"; echo "<td>" . $row['middle_name'] . "</td>"; echo "<td>" . $row['first_family_name'] . "</td>"; echo "<td>" . $row['second_family_name'] . "</td>"; echo "<td>" . $row['birthdate'] . "</td>"; echo "<td>" . $row['gender'] . "</td>"; echo "</tr>"; }echo "</table>"; }}mysql_close();?>() The following code is what I have already done, but I have just realised that the way I have done this will not enable me to display the online users in alphabetical order, I do not know a way how to do this. Any help or suggestions? Thanks $friend_query = mysql_query("SELECT * FROM friend_request WHERE user='{$user_id}'"); $friend_id_array = ""; while($row = mysql_fetch_assoc($friend_query)) { $friend_id = $row['friend_id']; $more_query = mysql_query("SELECT * FROM friend_request WHERE friend_id='{$user_id}'"); while($row_more = mysql_fetch_assoc($more_query)) { $more_friend_id = $row_more['user']; //all friends in an array $friend_id_array = $friend_id_array.$friend_id."/".$more_friend_id; $friend_id_array = explode('/', $friend_id_array); $friend_count = count($friend_id_array); //how many of the friends are online $online_count = 0; for($i=0;$i<$friend_count;$i++) { $query_online = mysql_query("SELECT loggedin, fname, mname, lname FROM users WHERE id='{$friend_id_array[$i]}'"); //get loggedin and names $row = mysql_fetch_assoc($query_online); $loggedin = $row['loggedin']; if($loggedin == "1") //if logged in { $online_count++; // final number off people online } } } } Hello I'm trying to set up a user area for my site where it displays the current logged in users ranking and other information in the future. <? ini_set('display_errors', 1); require_once "header.php"; $sql = "SELECT * FROM users WHERE username = ?"; if($stmt = mysqli_prepare($link, $sql)){ mysqli_stmt_bind_param($stmt, 's', $_SESSION['username']); if(mysqli_stmt_execute($stmt)){ $info = mysqli_fetch_array($stmt); echo "Current rank:" . $info['rank']; } else { echo "Can't find user"; } } mysqli_stmt_close($stmt); ?> That's the code I currently have but it gives me the error "but get an error message of mysqli_fetch_array() expects parameter 1 to be mysqli_result" Hi, I have a website where users can log on and edit their profile pic, name, biography etc. I was wondering about the correct way to:- Add data to the database through forms (Register.php) Display the data on a page Using mysql escape sting, however, the way I am currently using will display a '\' before any ' symbol. So it's >> it\'s ... Here is a snippet of the code I am using... Code: [Select] //insert data $about1 = mysql_real_escape_string($_POST['about']); //get $query = mysql_query("SELECT * FROM `staff` WHERE username='$username'"); $row = mysql_fetch_array($query); $about = $row['about']; echo $about; Hi I was just wondering if someone could send me a good tutorial on pulling several fields from a table and displaying them all in one drop down menu for people to select one of them. I dont know what this is called to I dont know what to research online. I would like assistance in displaying a company name in my web search results.
Below is my code:
<html> <head></head> <body> <?php if (!isset($_POST['q'])) { ?> <img src="/wvb-logo-slogen.png" border="0" /> <h2>Search</h2> <form method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>"> <input type="text" name="q" size="30" /> </form> <?php } else { ?> <img src="/wvb-logo-slogen.png" border="0" /> <h2>Search Results</h2> <?php try { // create object // $swish = new Swish('/usr/local/apache/htdocs/swish/index.swish-e'); $swish = new Swish('/var/www/html/pdf2/index.swish-e'); // get and run query from command-line $queryStr = htmlentities($_POST['q']); $result = $swish->query($queryStr); ?> Found <?php echo $result->hits; ?> match(es) for '<?php echo $queryStr; ?>'. <?php // iterate over result set // print details for each match while($r = $result->nextResult()) { ?> <p> <?php echo $r->swishreccount; ?> <strong> <a href="<?php echo '/pdf2', ltrim($r->swishdocpath, '.') ; ?>"> <?php echo $r->swishdocpath; ?> </a> </strong> (sco <?php echo $r->swishrank; ?>) <br/> <?php echo $r->swishdocpath; ?><br /> <?php //Split a filename by . $filenames = explode(".", $r->swishdocpath); //get 3 chars from $filenames to $country $country = substr($filenames[1],1,3); echo 'Country name: '.$country."<br />"; //$filenames[2] = explode(".", $r->swishdocpath); $year = substr($filenames[2],0,4); echo 'Year: '.$year; //$filenames = explode(".", $r->swishdocpath); $wvbnumber = substr($filenames[1],1,12); echo 'WVB Number: '.$wvbnumber; ?> </p> <?php } } catch (Exception $e) { die('ERROR: ' . $e->getMessage()); } } ?> </body> </html>As you can see I am able now display the WVB number, country name and year. But my question to anyone is how would I display the company name that it corresponds to? The names of the company are located in a .csv file called active_colist.csv and it is under the /var/www/html directory. This is what my /var/www/html directory looks like: [root@zeus wvbadmin]# cd /var/www/html [root@zeus html]# ls -l total 2140 -rw-r--r--. 1 root root 2110323 May 14 23:39 active_colist.csv -rw-r--r--. 1 root root 6678 Apr 30 13:25 favicon.ico -rw-r--r--. 1 root root 17256 May 5 16:02 h1 -rw-r--r--. 1 root root 113 Apr 29 16:45 hello.php -rw-r--r--. 1 root root 19 Apr 24 23:53 info.php drwxr-xr-x. 2 root root 12288 May 12 15:30 pdf2 lrwxrwxrwx. 1 root root 20 May 5 15:46 pdf3 -> /home/wvbadmin/pdf3/ -rw-r--r--. 1 root root 1227 May 6 16:33 pdfsearch2.php -rw-r--r--. 1 root root 1204 May 6 15:13 pdfsearch3.php -rw-r--r--. 1 root root 1625 May 19 23:27 pdfsearch.php -rw-r--r--. 1 root root 1838 Apr 30 13:10 search.php -rw-r--r--. 1 root root 10077 May 12 11:38 wvb-logo-slogen.png What is in the .csv file is the first 12 characters that correspond to the company name. What PHP code would I use to grab the first 12 characters of search results match them up with what is in the .csv file and display the proper company name? This is what is inside of the .csv file: WVB_NUMBER,PRIMARY_SHORT_COMPANY_NAME,CURR_ISO_CNTRY_OF_INCORP "AIA000030001","THE NATIONAL BANK OF ANGUILLA","AIA" "AIA000030003","ANGUILLA ELECTRICITY COMPANY","AIA" "AIA000030005","KMT-HANSA","AIA" "ALB000040001","BURSE E TIRANES","ALB" "ANT000020000","RORENTO","ANT" "ANT000030001","INTRUM JUSTITIA","SWE" "ANT000030002","ORTHOFIX INTERNATIONAL","ANT" "ANT000030004","HAL TRUST","ANT" "ARE000030001","MASHREQBANK","ARE" "ARE000030002","COMMERCIAL BANK OF DUBAI","ARE" Any assistance would be greatly appreciated. I am using the following php script to display all the files that are uploaded in a directory on a page. There are two files in the folder I do not want displayed: .htaccess & index.php. Can someone help me out and provide a little guidance about what I need to do to print all the file names EXCEPT for those two. I imagine some sort of if statement. CODE: Top of page: Code: [Select] <?php $dirname = "."; $dir = opendir($dirname); ?> Body: Code: [Select] <?php while(false != ($file = readdir($dir))) { if(($file != ".") and ($file != "..")) { echo("<a href='$dirname$file'>$file</a> <br />"); } } ?> Thanks so much! Helllo Every1 well im kinda new to php and i needed some help i was working on a page all my text boxes and check boxes are at the bottom of my file and like this //====================================================================== </script> </head> <body> <div style="margin-left: 170px"> <input type="checkbox" id="getitems" checked value="1">Run Plugin? <input type="checkbox" id="sellitm" checked value="1">Sell Items?<br><br> Item Name:<br><input type="text" id="itemd" value=""><br><br>How Many Cycles?:<br><input type="text" id="runtm" value="10"></div> <div style="margin-left: 170px"><br> <button id="btn_save" style="color:white;background-color:#00660F;border-width:1px;border-style:solid; "> Save settings </button> </div> '; echo $this->ObjectTable(); echo ' </body> </html> '; } } ?> and well i decided to do away wit one of the text boxes and use a drop down list instead that is populate from a text file and the only code that i could find that i was able to get working was this 1 <?php $text = file_get_contents("itemlist.txt"); $array = explode("\n",$text); echo "<select>"; foreach ($array as $value) { echo "<option value='$value'>$value</option>"; } echo "</select>"; and the problem im having is with that one it just stays at the top of the page when loaded like i have no way to position it... and im really stuck i tried saving it in another php and i tried using <?php include(); ?> function but it did not work if any1 could help me out that would be awsome. T.I.A I have a "select"-drop down bar and I want to have a numbered list in it, i've tried but it doesn't seem to be possible. Is there any way that i'm able to do this? Hi ,
I am pretty new to php. I would like to create a php website based on folders.
I have a code so far that shows the names of folder in a selection box. What I would like to achieve now is how i get the images inside the folder after I click on submit. I know how to get the images with a glob function. What I don't know is how to get the value of each specific folder name. How would I do that?
I have this code so far to get the names of the folders in the selection box:
<form action="test.php" method="post"> <select name="myDirs"> <option value="" selected="selected">Select a genre</option> <?php $dirs = glob("*", GLOB_ONLYDIR); foreach($dirs as $val){ echo '<option value="'.$val.'">'.$val."</option>\n"; } ?> </select> <input type="submit" name="submit2"> <?phpif (isset($_POST['submit2'])) Hi Guys, I have successfully managed to get my select drop down boxes to populate from a DB which i am very proud of as I'm still learning PHP but I really need some help on the next part please... I want to display a price based on the drop down selections so in my DB i have this... id colours size quantity sides price stock variations 1 1 A6 0-99 SINGLE 200 100g GLOSS 1 2 1 A6 100-199 SINGLE 300 100g GLOSS 1 What would i need to add to my PHP so that it checks the selections made by the user and displays the relevant price in the price filed in my page????? Hopefully someone can help. thanks Craig I'm useing a simple HTML drop-down list box. But now I want to be able to and an editable drop-down box so that if the particular item in the drop-down is not changed it won't update the database. But if a new value is selected it will update the DB with the new value.
I am not clear on a couple of things. should the valuse of the drop down be in a seperate DB table. And then the script to change the new value or keep the old.
I've googled this and can't seem to find a workable solution.
Thanks in advance,
I'm doing this activity where a user chooses a base timezone and when the user clicks convert the current time in the selected GMT will be converted to GMT-11 to GMT+13. As of now, I have these codes: act09_view.php: Code: [Select] <?php session_start(); $s="GMT "; echo "Select the base time zone:</br>"; for($n=-11;$n<=13;$n++) { if ($n>=0) $s="GMT +"; $gmt[]=$s . $n . "</br>"; } echo "<select name='gmt'>"; foreach ($gmt as $value) { echo '<option value="' . $value . '">' . $value . '</option>\n'; } echo '</select>'; //$_SESSION['value']=$value; ?> <form action="act09_process.php"> </br><input type='submit' value='Convert'/> </form> act09_process.php: Code: [Select] <?php session_start(); //$value=$_SESSION['value']; //echo $value; date_default_timezone_set('Asia/Manila'); $gmttime=date('M j, Y g:i:s A'); echo "The current date and time at" . " is " . $gmttime; ?> I've tried using session variables. I think I executed them incorrectly. The output is supposed to look like this: 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> Hi, I am trying to create a drop down list in php and I want the data to come from a table that I have created in phpmyadmin. The code that I have created allows me to select values from the drop down list and insert the rest of the data. However when I check the the table the SID and Cid are set to 0 and the grade field is empty and the comments field contains the grade. The SID and Cid are both composite keys. <?php $sql = "SELECT Cid FROM course"; $db1 = new DBStudent_Course(); $db1->openDB(); $result = $db1->getResult($sql); echo"<select name = Cid>"; while ($row = mysql_fetch_object($result)) { echo "<option value = '" . $row->Cid . "'>$row->Cid</option>"; } echo"</select>"; echo "</p>"; ?> <?php $sql = "SELECT SID FROM student"; $db1 = new DBStudent_Course(); $db1->openDB(); $result = $db1->getResult($sql); echo"<select name = SID>"; while ($row = mysql_fetch_object($result)) { echo "<option value = '" . $row->SID . "'>$row->SID</option>"; } echo"</select>"; echo "</p>"; ?> <?php if (!$_POST) { //page loads for the first time ?> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="post"> grade:<input type="text" name="grade"/><br/> comments:<input type="text" name="comments" /><br /> <input type="submit" value="Save" /> </form> <?php } else { $Cid = $_POST["Cid"]; $SID = $_POST["SID"]; $grade = $_POST["grade"]; $comments = $_POST["comments"]; $db1 = new DBStudent_Course(); $db1->openDB(); $numofrows = $db1->insert_student_course("", $SID, $Cid, $grade, $comments); echo "Success. Number of rows affected: <strong>{$numofrows}<strong>"; $db1->closeDB(); } ?> Hello, I'm trying to get a drop down list (ordinary html function, select option ...) but I want it to start from an image. When you click the image I want the drop down list to appear. Hove can I do this? /Pelle how do i loop this so that the option in the drop down list loop. i tried this but get an error Code: [Select] <select name="age"><?php for ($i=10; $i<71; $i++;) { echo "<option value='$i'>$i</option>"; } ?></select> |