PHP - Set Multiple Values To A Query String In Php
I have this form
<form action="" method="get" name="size"> Størrelse <hr><label><input type="radio" value="9" name="size" onchange="this.form.submit()">92 (2år)</label> <label><input type="checkbox" value="147" name="size" onchange="this.form.submit()">68 (6-9 mdr.) </label><label><input type="checkbox" value="150" name="size" onchange="this.form.submit()">86 (18-24 mdr.)</label> <input type="checkbox" value="149" name="size" onchange="this.form.submit()">80 (12-18 mdr.)</label> <label><input type="checkbox" value="148" name="size" onchange="this.form.submit()">74 (9-12 mdr.)</label> </form>I want to make it so that when the user clicks one checkbox for example size 68 and then checks size 80 I want both sizes to be in the URL query string. But every time the user clicks a new checkbox, the query string changes accordingly. Maybe with a separator like ?size=4:23 and then I will handle it with the DB stuff. Please tell me how to add multiple elements in the query string with this form, thank you! Edited by Stefany93, 21 May 2014 - 08:03 AM. Similar Tutorials
Table Issue - Multiple Location Values For User Pushes Values Out Of Row Instead Of Wrapping In Cell
Hi all, i've got a string ($currentcatid) which contains one number which changes dependant on which page the visitor is on.. ie it may be perhaps "23" or "17" . I need to do a check against this string to see if it contains any of the following values .. 31,32, 1, 24 . I cant remember how i did it before but i think it was with pipes.. something along the lines of if ($currentcatid =="31"||"32"||"1"||"24") { action } can anyone help? Thanks I am trying to make it echo if a string doesn't equal any of the values.
I have tried:
if(!preg_match("/none|Blue|Brown|Green|Grey)/i", $eyecolor)){ echo "Not an eye color"; } This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=354981.0 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>
This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=351561.0 Hi, I currently have a string with some values in it: $a_random_string="some random text, goes here - $123<br>some more random text goes here - $53 (text 123 )<br>ANother line of text - $126"; Now I want to add all the values that have a '$' before the value eg; $123. So in this case I would end up with: 302 How would I do this? Thanks, mme Hi, I have a string with the value of { "success": true, "delivered": true, "contactDetailsRequired": false, "message": "Signed For by: D ANDERSON ", "signature": "https://webservices.thedx.co.uk/PodImage/ImageHandler.ashx?tn=906732192165", "date": "21-07-2020", "serviceLevelName": "Consigned", "time": "13:33:19", "trackedProductName": "DataExchange" } How do i go about placing the values into variables so for example: $success = "true"; $delivered = "true"; $message = "Signed for by: D ANDERSON"; etc.... My mind has gone blank and im having one of those days, any help would be greatly appreciated. Thanks I have a DB of data: article-id, section-id, subsection-id, article-text. When a row is fetched I am displaying article, section, subsection as <h3>, <h4>, <h5> and then text in a <p>. Before outputting the text I want to scan it for other articles, sections, or subsections it may reference then turn that reference into a hyperlink. I read the PHP documentation but I can't find anything that translates to the basic commands of instring, indexof, and left/mid/right. Example: 1. Article Name 100. Article 1, section 1 100.a article 1, section 1, subsection a Text blah blah blah 105.f blah blah blah
I want to find that 105.f and turn it into a link. All my articles, sections, and subsections are in the DB so I know I can use an array of the number values as my items to look for, but I can't figure out how to look. okay all i need is a way to make 4 <OPTION> values into a string which i can compare to a row in my db. This is my form. Code: [Select] <select name='n1'> <option value='0'>0</option> <option value='1'>1</option> <option value='2'>2</option> <option value='3'>3</option> <option value='4'>4</option> <option value='5'>5</option> <option value='6'>6</option> <option value='7'>7</option> <option value='8'>8</option> <option value='9'>9</option> </select> <select name='n2'> <option value='0'>0</option> <option value='1'>1</option> <option value='2'>2</option> <option value='3'>3</option> <option value='4'>4</option> <option value='5'>5</option> <option value='6'>6</option> <option value='7'>7</option> <option value='8'>8</option> <option value='9'>9</option> </select> <select name='n3'> <option value='0'>0</option> <option value='1'>1</option> <option value='2'>2</option> <option value='3'>3</option> <option value='4'>4</option> <option value='5'>5</option> <option value='6'>6</option> <option value='7'>7</option> <option value='8'>8</option> <option value='9'>9</option> </select> <select name='n4'> <option value='0'>0</option> <option value='1'>1</option> <option value='2'>2</option> <option value='3'>3</option> <option value='4'>4</option> <option value='5'>5</option> <option value='6'>6</option> <option value='7'>7</option> <option value='8'>8</option> <option value='9'>9</option> </select> here is the php code which i tried but doesnt seem to work. Code: [Select] $n1 = $_POST['n1']; $n2 = $_POST['n2']; $n3 = $_POST['n3']; $n4 = $_POST['n4']; $string = ("" . $n1 . "" . $n2 . "" . $n3 . "" . $n4 . ""); echoing $string does give to correct numbers.. but when i try and compare it to my database it doesnt match. all help would be great. I've made a few attempts at this, but I'm likely not making much sense.... I'm working on how to phrase the question. I had a MySQL database where I used to combine user first AND last names in a single string... I called that string "Member" So if I filtered: www.mysite.com/members.php?Member=Peter It would find and display all Peters: Peter Rabbit and Peter Griffith and Pope Peter. This is what I want. I'm now keeping each name (first and last) in separate strings (as separate variables?), and I am combining them in an array to display on the website: Code: [Select] $First = $First; $Last = $Last; $member = array($Last, $First,); foreach ($Member as $key => $v ) if (!$v) unset ($Member[$key]); $Member = implode(', ', $Member); echo $Member; Now I've lost the ability to search all the members for Peter. So if I filtered: www.mysite.com/members.php?First=Peter ...it would work.... for Peter Rabbit and Peter Griffith, but not Pope Peter I cannot query the entire array? I can no longer check members (first and last names) for Wayne? www.mysite.com/members.php?Member=Peter I'm betting I can, but there's a lot more to it... and 8 hours of Googling haven't helped much. Thanks for listening. ~Wayne I'm going to create a web page with <iframe> tag & want that the src of <iframe> change as Hi, I've can use the following URL to filter the query below: www.mysite.com?levels=PreK ...this will show me alll the PreK members. www.mysite.com?levels=Elem ...this will show me all the Elem members. How do I filter it to show both me BOTH the PreK and Elem members? Do I need to change the query? WHERE ((user_info.Type LIKE '$Type%') and ((user_info.snr_First LIKE '%$name%') or (user_info.snr_Last LIKE '%$name%')) and (user_info.snr_Home_phone LIKE '$snr_Home_phone%') and (user_info.snre_eMail LIKE '$snre_eMail%') and ((user_info.PreK LIKE '$levels%') or (user_info.Elem LIKE '$levels%') or (user_info.MS LIKE '$levels%') or (user_info.HS LIKE '$levels%') or (user_info.College LIKE '$levels%') or (user_info.Admin LIKE '$levels%') or (user_info.Prvt LIKE '$levels%'))) ORDER BY user_info.$sort LIMIT $eu, $limit "; $result = mysql_query($query); Thanks. ~Wayne Say you have a string that you know has two, and exactly two, periods in it, like this...
$string = "3.12.8"How can you grab the three different values that are separated by periods (in this case, 3, 12 and ? I was thinking use strpos to find the position of the first period, then could use that info to grab everything up to that position. But then I couldn't figure out how you would find the position of the SECOND period. And even if I could get the exact positions of the two periods, it seems like there should be an easier way to simply retrieve values separated by specific characters. Is there a specific function for this type of thing, or was my initial though correct with having to do it in two parts essentially (find positions of periods, then use that knowledge to get the values)? Thanks! Hi guys,
I am using this code to open and close a pop up window, but as soon as i click the close button this
http://localhost/popup.php?random=&button=
automatically adds in the url, Please tell me what is wrong with the script
<script type="text/javascript"> $(document).ready(function(){ $('a.popup-window').click(function(){ var popupBox = $(this).attr('href'); $(popupBox).fadeIn(400); var popMargTop = ($(popupBox).height() + 24)/2; var popMargLeft = ($(popupBox).width() + 24)/2; $(popupBox).css({ 'margin-top' : -popMargTop, 'margin-left' : -popMargLeft }); $('body').append('<div id="mask"></div>'); $('#mask').fadeIn(400); return false; }); $('button.close,#mask').live('click', function(){ $('#mask,.popupInfo').fadeOut(400,function(){ $('#mask').remove(); }); return false; }); }); $(document).keyup(function(e){ if(e.keyCode ==27){ $('#mask,.popupInfo, #popup-box').fadeOut(400); return false; } }); </script> </head> <body> <a href="#popup-box" class="popup-window">Click</a> <div id="popup-box" class="popupInfo"> <form> <label>ANYTHING</label></br> <input type="text" name="random"/></br> <button type="submit" name="button" class ="close">close</button> </form> </div> </body> </html> Edited by chauhanRohit, 27 June 2014 - 09:46 AM. Hello everyone. I have a small problem. I might receive a ?aff=## or not on the end of my url when I get a visitor to my website. This depends on if they are sent from a affiliate website or not. If they are it shows fine on the home page but I loss it if they go to another page on my website. I need to keep this ?aff=## information while they look at the other pages. How would I capture and pass this information to my other pages as they surf my site? I tried this to no avail. $aff=$_GET['aff']; I have no clue no adding it back to the next page they go to. Any ideas would be helpful.. I have seen forums highlight what we searched on google to get to their site. is there a script that would allow me do the same??? Is it possible to add a query string for example some_var=jk84 to any sort of link be it, http://www.website.com , http://www.website.com/?some_id=4, or http://www.website.com/post=45&category=9 or http://www.website.com/somepost/ ? While adding that extra query string how can I make sure I'm not affecting the website's content or causing some script error? Hi there, im trying to have a form show up when user clicks "add joke". I need the variable to be retrieved from the url query string. I cant get the form to show up. I think its either an issue with the GET function at the top or the link down at the bottom. Please help! <?php // If the user wants to add a joke $_GET['addjoke'] = $addjoke; if (isset($addjoke)): ?> <FORM ACTION="<?php echo($PHP_SELF); ?>" METHOD=POST> <P>Type your joke he <BR> <TEXTAREA NAME="joketext" ROWS=10 COLS=40 WRAP> </TEXTAREA><BR> <INPUT TYPE=SUBMIT NAME="submitjoke" VALUE="SUBMIT"> </FORM> <?php else: // Connect to the database server $dbcnx = @mysql_connect("servername", "username", "password"); if (!$dbcnx) { echo( "<P>Unable to connect to the " . "database server at this time.</P>" ); exit(); } // Select the jokes database if (! @mysql_select_db("jhodara2") ) { echo( "<P>Unable to locate the joke " . "database at this time.</P>" ); exit(); } // If a joke has been submitted, // add it to the database. $joketext = $_POST['joketext']; $submitjoke = $_POST['submitjoke']; if ("SUBMIT" == $submitjoke) { $sql = "INSERT INTO jokes SET " . "JokeText='$joketext', " . "JokeDate=CURDATE()"; if (mysql_query($sql)) { echo("<P>Your joke has been added.</P>"); } else { echo("<P>Error adding submitted joke: " . mysql_error() . "</P>"); } } echo("<P> Here are all the jokes " . "in our database: </P>"); // Request the text of all the jokes $result = mysql_query( "SELECT JokeText FROM jokes"); if (!$result) { echo("<P>Error performing query: " . mysql_error() . "</P>"); exit(); } // Display the text of each joke in a paragraph while ( $row = mysql_fetch_array($result) ) { echo("<P>" . $row["JokeText"] . "</P>"); } // When clicked, this link will load this page // with the joke submission form displayed. echo("<P><A HREF='$PHP_SELF?addjoke=1'>Add a Joke!</A></P>"); endif; ?> see the problem live at http://www.freewaycreative.com/insert2.php |