PHP - Printing Values To A Drop Down Box
i'm trying to print out values from a table into a drop down box, but my code doesnt seem to work. when i test it, there are no values in the drop down box.
if someone could find the problem, that would be great. <form name="add_sub_section" method="post" action="<?php echo $_SERVER['../PHP_SELF']; ?>"> Sub Section Name <input type="text" name="sub_section_title" maxlength="200" /><br/><br/> Sub Section desc <textarea name="sub_section_desc" rows="4" columns="30" /></textarea><br/><br/> SECTION <?php $list = "SELECT section_title FROM section_main"; echo "<select name='section_title'>"; while ($a = mysql_fetch_row($list)) { for ($j = 0; $j < mysql_num_fields($list); $j++) { echo "<option value=". $a[$j] . ">". $a[$j] . "</option>"; } } echo "</select>"; ?> <br/><br/> <input type="submit" name="submit" value="Add Section"/> </form> the connection to the table works, so i havnt put that code in. there's no formatting for the html yet, i just want to get the php working first Thanks Similar Tutorials
Table Issue - Multiple Location Values For User Pushes Values Out Of Row Instead Of Wrapping In Cell
Hey guys. I have ran into a problem once again. I want to print a list of data I have in my database being monsters (ID, Name, HP, attack) I want to be able to print them fromt he database then get the "ID" of the monster being selected by a submit button to give the id of that row in some form (a POST?) so i can get the information for that monster in a SELECT when the button is hit. I will try show you what im trying to do. Code: [Select] //Grt the id from the table print at the bottom. $monster_id = $_POST["monsterid"]; //this is at the top to get stats on the monster the user has selected to fight $query="SELECT * FROM monsters WHERE id='$monster_id'"; $result=mysql_query($query); $result=mysql_fetch_array($result); $monster_exp=$result["exp"]; $exp_dead = round(($monster_exp/100) * 10); $monster_hp =$result["hp"]; $goldwon =$result["gold"]; $mindam =$result["mindam"]; $maxdam =$result["maxdam"]; // my battle code goes here using the stats I want above. ------------------------------------------------------------------------------ //This is where the user selects the monster they want to fight. $query="SELECT * FROM monsters"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; <form action="training.php" method="post"> <table border='0' width="400" class="tablee"> <tr> <th>Monster</th> <th>Level</th> <th>HP</th> <th>Protection</th> <th>Fight?</th> </tr> <? $query="SELECT * FROM monsters"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); $i=0; while ($i < $num) { $id=mysql_result($result,$i,"id"); $name=mysql_result($result,$i,"name"); $level=mysql_result($result,$i,"lvl"); $hp=mysql_result($result,$i,"health"); $pro=mysql_result($result,$i,"pro"); ?> <tr> <th><? echo $mon_name; ?> </th> <th><? echo $mon_level; ?> </th> <th><? echo $mon_hp; ?> </th> <th><? echo $mon_pro; ?> </th> <th><input type="hidden" value="<? echo $mon_id; ?>" name="monsterid" /> <input type="submit" value="Fight!" name="submit" /></th> </tr> <? $i++; } ?> </table> </form> I hope this makes sense because I am really having problems. My gues is use an array but I could get it to work. PS: I did a get and it sends ALL the IDs instead of the selected row. Thanks for any help guys, Ruddy I've got two tables (classOfferings, instructors). The fields I'm dealing with are 'co.instructorId', 'i.instructorId', 'i.fName', 'i.lName'. I have a form with dynamically generated drop downs. What I would like to do is check classOfferings table to see which instructors are teaching classes then display them in drop down with the 'instructorId' as the value and 'fName' and 'lName' as the user selectable part. So I have found the distinct 'instructorId', but I can't make 'fName' and 'lName' appear as the user selectable part. The code below produces a drop down which has invisible values, but still posts a value. <select size="1" name="instructor"> <option value="" selected>Search By Teacher...</option> <? $instrList=mysql_query("select distinct instructorId from classOfferings order by instructorId asc"); $instrNameList=mysql_query("select fName, lName from instructors where classOfferings.instructorId = instructors.instructorId order by lName asc"); // Show records by while loop. while($instructor_list=mysql_fetch_assoc($instrList)){ $instrNames = ($instr_Name['fName']) . ($instr_Name['lName']); ?> <option value="<? echo $instructor_list['instructorId']; ?>" <? if($instructor_list['instructorId']==$select){ echo "selected"; } ?>> <? echo $instrNames; ?></option> <? // End while loop. } ?> </select> I have 64 rows of players and want each User to be able to choose to bookmark an player, as well as unbookmark it too. I have a bookmark table set up, and each time a User decides to bookmark(+) or unbookmark(-) an player a row is created in the data table. (Matching the player ID and User ID) That's working fine. A query reads the most recent row for each player to determine if there is a + or - button next to each player. Testing the query and adding some dummy data, that part of it works too. However, the issue is the initial state, which I want to be a +. Once I go live, the table will be empty, nothing for the query to return/produce. How do I create an initial state of a + with no rows and have it not used or swapped out when Users start clicking + or -?
$query = "SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."'&&'". $id ."' = playerID ORDER BY b.id desc LIMIT 1 "; $results = mysqli_query($con,$query); echo mysqli_error($con); while($row = mysqli_fetch_assoc($results)) { echo $row['bookmark']; if($row['bookmark'] == 0) { echo '-'; // this is where a form goes to remove a bookmark } else { echo '+'; // this is where a form goes to add a bookmark } } I tried to get it with CASE, but I don't think that's the right path. I also looked at UNION. I was able to get it to produce an initial state of +, but it still printed the already made up sample data too (so I have three instances of ++ or +-). (Players 2, 4 and 4)
Here is the what the UNION query looked like: $query = "(SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."'&&'". $id ."' = playerID ORDER BY b.id desc LIMIT 1) UNION (SELECT b.id, bookmark,playerID,userID,p.id FROM a_player_bookmark b LEFT JOIN a_players p ON '". $id ."' = playerID WHERE userID = '". $userID ."' ORDER BY p.id desc LIMIT 1) ";
Hi guys, Im currently doing a project for college and i have experienced some problems with saving my php drop down values to my database. im am getting no error but my values are not being stored to my db.If anyone could help me or point me in the correct direction then id be grateful. Ive attached my code. Ive been scanning over and over this code and I cant work out why my 2nd drop down menu doesnt have unique values. Please if anyone can give me guidance, you never know I may be able to get rid of my headache! Code: [Select] <body> <p> <form action="" method="post"> <select name="drop_1" id="drop_1"> <option value="" selected="selected" disabled="disabled">Select a Category</option> <?php getTierOne(); ?> </select> <span id="wait_1" style="display: none;"> <img alt="Please Wait" src="ajax-loader.gif"/> </span> <span id="result_1" style="display: none;"></span> </form> </p> <p> <?php if(isset($_POST['submit'])){ $drop = $_POST['drop_1']; $tier_two = $_POST['Subtype']; echo "You selected "; echo $drop." & ".$tier_two; } ?> </body> Code: [Select] <?php function getTierOne() { $result = mysql_query("SELECT DISTINCT Type FROM business") or die(mysql_error()); while($tier = mysql_fetch_array( $result )) { echo '<option value="'.$tier['Type'].'">'.$tier['Type'].'</option>'; } } if($_GET['func'] == "drop_1" && isset($_GET['func'])) { drop_1($_GET['drop_var']); } function drop_1($drop_var) { include_once('db.php'); $result = mysql_query("SELECT DISTINCT Subtype FROM business WHERE Type='$drop_var'") or die(mysql_error()); echo '<select name="Subtype" id="Subtype"> <option value=" " disabled="disabled" selected="selected">Choose one</option>'; while($drop_2 = mysql_fetch_array( $result )) { echo '<option value="'.$drop_2['Subtype'].'">'.$drop_2['Subtype'].'</option>'; } echo '</select> '; echo '<input type="submit" name="submit" value="Submit" />'; } ?> I am trying to make a Web Form for people to fill out that has two drop down menus where i want the first drop down menu's selection changes the values of the selections in the second drop down. ((IE. If the first drop down value is "product 01" then the second drop down shows values "Red, Green, Blue" while if the first drop down value is "product 02" then the second drop down shows values "Yellow, Green")) Anyone have any ideas? Thanks in Advance. I have several drop down boxes. When submit is clicked it execute query on another page. Problem is when submit is clicked selected values are return to defaults. Is it possible for the values to be remembered after submitting them? Part of the drop down code: Code: [Select] <?php $result = mysql_query("SELECT * FROM product GROUP BY Rim"); ?> <select id="Rim" name="Rim" selected="selected" style="width:158px;position:static;z-index:-1;"> <option value="rim" selected="selected"><?php echo "Rim"; ?></option> <?php while ($row = mysql_fetch_array($result)) { echo "<option>" . $row['Rim'] . "</option>"; echo "<br />"; } ?> </select> Basically, I have a database table called 'users' and I would like to populate a drop down box with these values of 'users'. How?? - to call upon the values is this: 'upduser2' Right now, all I am using is a text box, in where you have to type in the users name manually (this is so an admin can change variables and settings according to that current user). This is what I am using so far: <h3>Update User Level</h3> <? echo $form->error("upduser"); ?> <table> <form action="adminprocess.php" method="post"> <tr> <td> Username:<br /> <input type="text" name="upduser" maxlength="30" value="<? echo $form->value("upduser"); ?>" /></td> <td> Level:<br /> <select name="updlevel"> <option value="1">1 </option> //example settings <option value="9">9 </option> </select></td> <td><br /> <input type="hidden" name="subupdlevel" value="1" /> <input type="submit" value="Update Level" /></td> </tr> </form> </table></td> </tr> Much help would be appreciated. Hi guys, I had a problem before which is similar to the problem im about to describe, however Pikachu helped me solve the last problem so a big thanks to him! However this problem is slightly different and im struggling to find a solution. I will first describe the problem I had which pikachu helped me solve as it would be easier for me to describe this past problem. I have an update form, so a user can edit existing records which are pulled from a database. When the user changes the values in a text field then submits the form, the values in the text fields updates fine. However if they change the values in the text box and then tries to submit the form but there was an error, the values in the text fields go back to the values from the database and the user has to change the text fields again. Well this problem was solved with the help of pikachu and the this is what I did... <?php if(isset($_POST['title'])){echo htmlspecialchars($_POST['title']);} else if (isset($title)) {echo htmlspecialchars($title);}?> Again, the above works fine however the problem I have now is the same problem as described above however it relates to drop down menus and not text fields. I can't seem to figure out how to retain the values in a drop down menu the same way I have for text fields. Below is the code that im using that I thought would work however it isnt working, the values of the drop down menu (if there was an error) are going back to the values from the database. Heres the code... <option value="Psychopathic" <?php if ((isset($_POST['category']))&&($_POST['category'] == 'Psychopathic')) { echo ' selected=selected'; } else if ((isset($category))&&($category == 'Psychopathic')) { echo ' selected=selected'; } ?>>Psychopathic</option> Does anybody know what i am doing wrong and how i can fix this problem? I understand what i need to do but i cant seem to get the code to do what i want to do and thats to retain values of a drop down menu when the page is returned with an error. Any help would be much appreciated. AJay Hi all, I'm just wondering if there's an easier way of doing what accomplishing the following: I have a value in my database which represents a selection in a drop down menu, i want to read it from the database and have it automatically selected depending on the stored data. I have the following working but just wondered if there was an easier way to get the same result: Code: [Select] <?php //database connection $query = "SELECT id FROM `tablename` WHERE username='$username'"; $result = mysql_query($query); $row = mysql_fetch_object($result); $id = $row->id; $id = (int)$id; ?> <select name="id"> <option value="">Select your option...</option> <option value="1" <?php if (($id - 1) === 0) { echo 'selected="selected"'; }?>>Selection 1</option> <option value="2"<?php if (($id - 2) === 0) { echo 'selected="selected"'; }?>>Selection 2</option> </select> Sorry if it's not very clear, i'll explain best i can if anyone can help. Thanks I'm simply trying to set up a form where, if when a user clicks 'Submit', and then 'Back', the values from the form are preserved. My question is, how do I preserve the values of drop down menus. The following is a snippet of my code: Code: [Select] <select name="dropdown_dept" id="dept_list"> <option value=0><?php echo "Please select one..."?></option> <?php $dropdown_dept = "select dept_name from departments"; $result_dept = $db_conn->query($dropdown_dept); if (!$result_dept) { echo '<p>Unable to get department data.</p>'; return false; } for($i=0; $i<$result_dept->num_rows; $i++) { $app_name_row = $result_dept -> fetch_array(); ?> <option><?php echo($app_name_row[0]); ?></option> <? } ?> </select> Above is where I have set up a drop down menu of departments. Given that code, how can I preserve the department name after a user clicks 'Submit'? GREAT this forum - JUST GREAT !... Issue: All data entered into my online form was lost (blanked out) and the form returned correctly with message "wrong verification code", when submitted with the wrong verification code. However, going through this great forum I managed to get all - manually entered - data back ! I placed value="<?php echo $_GET['the_field_name'];?>"/ after each input field. BUT... not so with input fields entered from drop-down menu ! How do I put a similar string for the field "Payment by" in this sample: <tr> <td class="table-inquire" width="47%"> <font face="Verdana" size="1" color="#000042"> Payment by:</font></td> <td class="table-inquire" width="51%" colspan="2"> <font color="#400000" face="Verdana"> <select name="payment" size="1"> <option value="VISA">VISA</option> <option value="MASTER">MASTER</option> <option value="CASH">CASH</option> <option value="T/T Banktransfer">T/T Banktransfer</option> <option selected>Please select</option> </select></font><font size="2" color="#400000" face="Verdana"></font></td> </tr> Any advise greatly appreciated. Thanks. Hi i have this drop down list for date which contain 3 selects DAY MONTH YEAR hwo can i make so that when update form select keeps the same value has before help please <?php $months = array('','January','February','March','April','May','June','July','August','September','October','November','December'); echo '<select name="month_of_birth">'; for ($i=1;$i<13;++$i) { echo '<option value="' . sprintf("%02d",$i) . '">' . $months[$i] . '</option>'; } echo '</select>'; echo '<select name="day_of_birth">'; for ($i=1;$i<32;++$i) { echo '<option value="' . sprintf("%02d",$i) . '">' . $i . '</option>'; } echo '</select>'; echo '<select name="year_of_birth">'; $year = date("Y"); for ($i = $year;$i > $year-50;$i--) { $s = ($i == $year)?' selected':''; echo '<option value="' . $i . '" ' . $s . '>' . $i . '</option>'; } echo '</select>'; ?> Hello all Ok here is the problem... I want when a user inputs the requested data to the text fields , the script to insert those data in the prope table depending on the choise the user does by choosing one option from the drop down menu. Below is the php code (apparently not working) $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } $site_type = $_REQUEST['category_selection']; if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type = "Web_Sites")) { $insertSQL = sprintf("INSERT INTO partner_sites (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['url_field'], "text"), GetSQLValueString($_POST['title_field'], "text"), GetSQLValueString($_POST['anchor_field'], "text"), GetSQLValueString($_POST['description_field'], "text"), GetSQLValueString($_POST['webmaster_nane_field'], "text"), GetSQLValueString($_POST['webmaster_email_field'], "text"), GetSQLValueString($_POST['category_selection'], "text")); mysql_select_db($database_content_conn, $content_conn); $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error()); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type = "Blogs")) { $insertSQL = sprintf("INSERT INTO partner_blogs (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['url_field'], "text"), GetSQLValueString($_POST['title_field'], "text"), GetSQLValueString($_POST['anchor_field'], "text"), GetSQLValueString($_POST['description_field'], "text"), GetSQLValueString($_POST['webmaster_nane_field'], "text"), GetSQLValueString($_POST['webmaster_email_field'], "text"), GetSQLValueString($_POST['category_selection'], "text")); mysql_select_db($database_content_conn, $content_conn); $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error()); } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "link_submission") && ($site_type = "Directories")) { $insertSQL = sprintf("INSERT INTO partner_directories (url, url_title, anchor_text, `description`, webmaster_name, webmaster_email, category) VALUES (%s, %s, %s, %s, %s, %s, %s)", GetSQLValueString($_POST['url_field'], "text"), GetSQLValueString($_POST['title_field'], "text"), GetSQLValueString($_POST['anchor_field'], "text"), GetSQLValueString($_POST['description_field'], "text"), GetSQLValueString($_POST['webmaster_nane_field'], "text"), GetSQLValueString($_POST['webmaster_email_field'], "text"), GetSQLValueString($_POST['category_selection'], "text")); mysql_select_db($database_content_conn, $content_conn); $Result1 = mysql_query($insertSQL, $content_conn) or die(mysql_error()); } And the html form <form action="<?php echo $editFormAction; ?>" method="POST" enctype="multipart/form-data" name="link_submission" id="link_submission"> <table width="630" border="0" align="center" cellpadding="5" cellspacing="5"> <tr> <td width="76">URL:*</td> <td width="519"><label for="url_field"></label> <span id="sprytextfield1"> <label for="url_field"></label> <input name="url_field" type="text" id="url_field" size="50" /> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td> </tr> <tr> <td>Anchor Text:*</td> <td><label for="anchor_field"><span id="sprytextfield2"> <input type="text" name="anchor_field" id="anchor_field" /> <span class="textfieldRequiredMsg">A value is required.</span></span></label></td> </tr> <tr> <td>URL Title:*</td> <td><label for="title_field"><span id="sprytextfield3"> <input type="text" name="title_field" id="title_field" /> <span class="textfieldRequiredMsg">A value is required.</span></span></label></td> </tr> <tr> <td>Description:*</td> <td><span id="sprytextarea1"> <label for="description_field"></label> <textarea name="description_field" id="description_field" cols="45" rows="3"></textarea> <span id="countsprytextarea1"> </span><span class="textareaRequiredMsg">A value is required.</span><span class="textareaMaxCharsMsg">Exceeded maximum number of characters.</span></span></td> </tr> <tr> <td>Webmaster Name:*</td> <td><label for="textfield2"><span id="sprytextfield4"> <input type="text" name="webmaster_nane_field" id="webmaster_nane_field" /> <span class="textfieldRequiredMsg">A value is required.</span></span></label></td> </tr> <tr> <td>Webmaster E-mail:*</td> <td><label for="textfield3"><span id="sprytextfield5"> <input name="webmaster_email_field" type="text" id="webmaster_email_field" size="40" /> <span class="textfieldRequiredMsg">A value is required.</span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></label></td> </tr> <tr> <td>Category:*</td> <td><span id="spryselect1"> <label for="category_selection"></label> <select name="category_selection" id="category_selection"> <option>Select An Option</option> <option value="Web_Sites">Web Sites</option> <option value="Blogs">Blogs</option> <option value="Directories">Directories</option> </select> <span class="selectRequiredMsg">Please select an item.</span></span></td> </tr> <tr> <td> </td> <td><label for="select"></label> <input type="submit" name="button" id="button" value="Url Submission" /></td> </tr> </table> <input type="hidden" name="MM_insert" value="link_submission" /> </form> Im begging for your help..... Dear All Members here is my table data.. (4 Columns/1row in mysql table)
id order_no order_date miles How to split(miles) single column into (state, miles) two columns and output like following 5 columns /4rows in mysql using php code.
(5 Columns in mysql table) id order_no order_date state miles 310 001 02-15-2020 MI 108.53 310 001 02-15-2020 Oh 194.57 310 001 02-15-2020 PA 182.22
310 001 02-15-2020 WA 238.57 ------------------my php code -----------
<?php
if(isset($_POST["add"]))
$miles = explode("\r\n", $_POST["miles"]);
$query = $dbh->prepare($sql);
$lastInsertId = $dbh->lastInsertId(); if($query->execute()) {
$sql = "update tis_invoice set flag='1' where order_no=:order_no"; $query->execute();
} ----------------- my form code ------------------
<?php -- Can any one help how to correct my code..present nothing inserted on table
Thank You Edited February 8, 2020 by karthicbabuHi, My company has 240+ locations and as such some users (general managers) cover multiple sites. When I run a query to pull user information, when the user has multiple sites to his or her name, its adds the second / third sites to the next columns, rather than wrapping it inside the same table cell. It also works the opposite way, if a piece of data is missing in the database and is blank, its pull the following columns in. Both cases mess up the table and formatting. I'm extremely new to any kind of programming and maybe this isn't the forum for this question but figured I'd give it a chance since I'm stuck. The HTML/PHP code is below: <table id="datatables-column-search-select-inputs" class="table table-striped" style="width:100%"> <thead> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> <th>Actions</th> </tr> </thead> <tbody> <?php //QUERY TO SELECT ALL USERS FROM DATABASE $query = "SELECT * FROM users"; $select_users = mysqli_query($connection,$query);
// SET VARIABLE TO ARRAY FROM QUERY while($row = mysqli_fetch_assoc($select_users)) { $user_id = $row['user_id']; $user_firstname = $row['user_firstname']; $user_lastname = $row['user_lastname']; $username = $row['username']; $user_phone = $row['user_phone']; $user_image = $row['user_image']; $user_title_id = $row['user_title_id']; $user_role_id = $row['user_role_id'];
// POPULATES DATA INTO THE TABLE echo "<tr>"; echo "<td>{$user_id}</td>"; echo "<td>{$user_firstname}</td>"; echo "<td>{$user_lastname}</td>"; echo "<td>{$username}</td>"; echo "<td>{$user_phone}</td>";
//PULL SITE STATUS BASED ON SITE STATUS ID $query = "SELECT * FROM sites WHERE site_manager_id = {$user_id} "; $select_site = mysqli_query($connection, $query); while($row = mysqli_fetch_assoc($select_site)) { $site_name = $row['site_name']; echo "<td>{$site_name}</td>"; } echo "<td>{$user_title_id}</td>"; echo "<td>{$user_role_id}</td>"; echo "<td class='table-action'> <a href='#'><i class='align-middle' data-feather='edit-2'></i></a> <a href='#'><i class='align-middle' data-feather='trash'></i></a> </td>"; //echo "<td><a href='users.php?source=edit_user&p_id={$user_id}'>Edit</a></td>"; echo "</tr>"; } ?>
<tr> <td>ID</td> <td>FirstName</td> <td>LastName</td> <td>Username</td> <td>Phone #</td> <td>Location</td> <td>Title</td> <td>Role</td> <td class="table-action"> <a href="#"><i class="align-middle" data-feather="edit-2"></i></a> <a href="#"><i class="align-middle" data-feather="trash"></i></a> </td> </tr> </tbody> <tfoot> <tr> <th>ID</th> <th>FirstName</th> <th>LastName</th> <th>Username</th> <th>Phone #</th> <th>Location</th> <th>Title</th> <th>Role</th> </tr> </tfoot> </table>
Hi all, I'm a first time poster here and I would really appreciate some guidance with my latest php challenge! I've spent the entire day googling and reading and to be honest I think I'm really over my head and need the assistance of someone experienced to advise the best way to go! I have a multi dimensional array that looks like (see below); the array is created by CodeIgniter's database library (the rows returned from a select query) but I think this is a generic PHP question as opposed to having anything to do with CI because it related to working with arrays. I'm wondering how I might go about searching the array below for the key problem_id and a value equal to a variable which I would provide. Then, when it finds an array with a the matching key and variable, it outputs the other values in that part of the array too. For example, using the sample data below. How would you recommend that I search the array for all the arrays that have the key problem_id and the value 3 and then have it output the value of the key problem_update_date and the value of the key problem_update_text. Then keep searching to find the next occurrence? Thanks in advance, as above, I've been searching really hard for the answer and believe i'm over my head! Output of print_r($updates); CI_DB_mysql_result Object ( [conn_id] => Resource id #30 [result_id] => Resource id #35 [result_array] => Array ( ) [result_object] => Array ( ) [current_row] => 0 [num_rows] => 5 [row_data] => ) Output of print_r($updates->result_array()); Array ( [0] => Array ( [problem_update_id] => 1 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Some details about a paricular issue [problem_update_active] => 1 ) [1] => Array ( [problem_update_id] => 4 [problem_id] => 3 [problem_update_date] => 2010-10-01 [problem_update_text] => Another update about the problem with an ID of 3 [problem_update_active] => 1 ) [2] => Array ( [problem_update_id] => 5 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of four [problem_update_active] => 1 ) [3] => Array ( [problem_update_id] => 6 [problem_id] => 4 [problem_update_date] => 2010-10-12 [problem_update_text] => An update about the problem with an ID of 6 [problem_update_active] => 1 ) [4] => Array ( [problem_update_id] => 7 [problem_id] => 3 [problem_update_date] => 2010-10-12 [problem_update_text] => Some new update about the problem with the ID of 3 [problem_update_active] => 1 ) ) Hi all, Just curious why this works: Code: [Select] while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){ $import="INSERT into $prodtblname ($csvheaders1) values('$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]')"; } And this does not: $headdata_1 = "'$data[0]','$data[1]','$data[2]','$data[3]','$data[4]','$data[5]','$data[6]'"; while (($data = fgetcsv($handle, 1000, ",")) !== FALSE){ $import="INSERT into $prodtblname ($csvheaders1) values($headdata_1)"; }it puts $data[#'s] in the database fields instead of the actual data that '$data[0]','$data[1]'... relates to. I wrote a script to create the values in $headdata_1 based on the number of headers in $csvheaders1 but can't seem to get it working in the sql statement. Thanks hello all, i know that php is server side. if i have a printer attached to the server, can i have users press a button and have it print there? hi everyone I have a small user & business Directory and for it, I use a .htaccess ReWrite. My .htaccess file looks like Code: [Select] RewriteEngine On RewriteRule ^([^/.]+)$ index.php?q=$1 [QSA,L] so basically when I run Code: [Select] http://localhost/Johnsons/ then it treats that like Code: [Select] http://localhost/index.php?q=Johnsons I then do a PHP Query to find the result, I use the following; print "You looked up $_GET['q']"; $result = mysql_query("SELECT `name` FROM `directory` WHERE `name` = '".$_GET['q']."'"); while($row = mysql_fetch_array($result)) { print $row['name']; } this all works fine. The problem I now have is that I have been sent some new data in a SQL database import file and it contains entries such as Dugāriy T-ī-Corā but when I try and run http://localhost/Dugāriy/ or http://localhost/T-ī-Corā/ it does not return the correct value and instead it either misses characters or it exchanges one character for another, (ā is swapped "a" as an example). It seems this is due to a mix of Special Characters & Accents within words such as ā ū ī I have tried altering the META charset tag without any luck, I have also tried print utf8_encode($_GET['q']); print urlencode($_GET['q']); but nothing seems to work. Any idea on how I can solve this? Thanks very much J |