PHP - Select Pieces From Checkboxess
so I need to know how to make it so that this code
Code: [Select] <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ [URL='http://www.flashbuilding.com/']www.flashbuilding.com[/URL] -----------------------June 20, 2008----------------------- */ // Here we run a login check if (!isset($_SESSION['id'])) { echo 'Please <a href="/login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include include_once "connect_to_mysql.php"; // Place Session variable 'id' into local variable $userid = $_SESSION['id']; if (isset($_POST['submitted'])) { include('connect1.php'); $category = "name"; $criteria = $_POST['criteria'] ; setcookie("criteria", $criteria, time()+10); setcookie("category", $category, time()+10); $query = ("SELECT name, badges, rank, userid FROM members WHERE $category LIKE '%".$criteria."%'"); $result = mysqli_query($dbcon, $query) or die('error getting data'); setcookie("query12", $query, time()+10); } // Process the form if it is submitted $sql = mysql_query("SELECT * FROM members WHERE userid='$userid'"); while($row = mysql_fetch_array($sql)){ $name = $row["name"]; $phone = $row["phone"]; $username = $row["username"]; $address = $row["address"]; $city = $row["city"]; $state = $row["state"]; $zip = $row["zip"]; $cell = $row["cell"]; $email = $row["email"]; $accounttype = $row["accounttype"]; $rank = $row["rank"]; $badges = $row["badges"]; } ?> will select all people from this code that are checked and will still set cookies. Code: [Select] <?php $select = mysql_query("SELECT * FROM members") or die(mysql_error()); while ($member = mysql_fetch_array($select)) { echo '<input type="checkbox" name="criteria" value="'.$member[name].'">'.$member[name].'<br>'; } ?> I have results displaying later on and it only displays the last name checked. please help. I can't figure out what to use here Similar TutorialsThis script is supposed to run in the command line. Like the title says, I need to: Import some columns (input the names with an argument) from a .CSV file Split the column into blocks of 500 lines Translate this pieces Put them back into the original file I already have some code but it is unfinished and not working: <?php //name of the .CSV file $filename = $argv[1]; //name of the column to be translated $header_name = $argv[2]; //open file $file_handle = fopen($filename, "r"); $i=0; $j=0; $counter = 0; $translated = ''; $string = ''; while (!feof($file_handle) ) { $counter++; $line_of_text = fgetcsv($file_handle, 1024); //find the column id that contains the header name. // headers are always on the the first line if ( $counter == 1 ){ while ($line_of_text[$i] != $header_name) $i++; $header_id = $i; } //create the blocks $string .= $line_of_text[$i]; if ($counter % 500 == 0) { $gt = new GoogleTranslateWrapper(); $translated .= $gt->translate($string, "en"); } } //Write the translate column in the same .CSV file fclose($file_handle); ?> Any help in rewriting this to work? hirealimo.com.au/code1.php this works as i want it: Quote SELECT * FROM price INNER JOIN vehicle USING (vehicleID) WHERE vehicle.passengers >= 1 AND price.townID = 1 AND price.eventID = 1 but apparelty selecting * is not a good thing???? but if I do this: Quote SELECT priceID, price FROM price INNER JOIN vehicle....etc it works but i lose the info from the vehicle table. but how do i make this work: Quote SELECT priceID, price, type, description, passengers FROM price INNER JOIN vehicle....etc so that i am specifiying which colums from which tables to query?? thanks I have 2 queries that I want to join together to make one row
Dear All, I wish to have 2 drop down boxes, Country Select Box and Locality Select Box. The locality select box will be affected by the value chosen in the country select box. All is working fine except that the locality select box is not being populated. I know that the problem is in the sql statement WHERE country_id='$co' because i am having an error that $co is an undefined variable. All the rest works fine because i have replaced the $co variable directly with a number (say 98) for a particular country id and it worked fine. In what way can i define this variable $co so that it is accepted by my sql statement? Thank you for your help in advance. MySQL Tables indicated below: CREATE TABLE countries( country_id INT(3) UNSIGNED NOT NULL AUTO_INCREMENT, country_name VARCHAR(30) NOT NULL, PRIMARY KEY(country_id), UNIQUE KEY(country_name), INDEX(country_id), INDEX(country_name)) ENGINE=MyISAM; CREATE TABLE localities( locality_id INT(10) UNSIGNED NOT NULL AUTO_INCREMENT, country_id INT(3) UNSIGNED NOT NULL, locality_name VARCHAR(50), PRIMARY KEY (locality_id), INDEX (country_id), INDEX (locality_name)) ENGINE=MyISAM; Extract PHP script included below: // connect to database require_once(MYSQL); if(isset($_POST['submitted'])) { // trim the incoming data /* this line runs every element in $_POST through the trim() function, and assigns the returned result to the new $trimmed array */ $trimmed=array_map('trim',$_POST); // clean the data $co=mysqli_real_escape_string($dbc,$trimmed['country']); $lc=mysqli_real_escape_string($dbc,$trimmed['locality']); } ?> <form action="form.php" method="post"> <p>Country <select name="country"> <option>Select Country</option> <?php $q="SELECT country_id, country_name FROM countries"; $r=mysqli_query($dbc,$q) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); while($row=mysqli_fetch_array($r)) { $country_id=$row[0]; $country_name=$row[1]; echo '<option value="' . $country_id . '"'; if(isset($trimmed['country']) && ($trimmed['country']==$country_id)) echo 'selected="selected"'; echo '>' . $country_name . '</option>\n'; } ?> </select> </p> <p>Locality <select name="locality"> <option>Select Locality</option> <?php $ql="SELECT locality_id, country_id, locality_name FROM localities WHERE country_id='$co' ORDER BY locality_name"; $rl=mysqli_query($dbc,$ql) or trigger_error("Query: $q\n<br />MySQL Error: " . mysqli_error($dbc)); while($row=mysqli_fetch_array($rl)) { $locality_id=$row[0]; $country_id=$row[1]; $locality_name=$row[2]; echo '<option value="' . $locality_id . '"'; if(isset($trimmed['locality']) && ($trimmed['locality']==$locality_id)) echo 'selected="selected"'; echo '>' . $locality_name . '</option>\n'; } // close database connection mysqli_close($dbc); ?> </select> </p> <p><input type="submit" name="submit" value="Submit" /></p> <input type="hidden" name="submitted" value="TRUE" /> </form> Hi all, Im trying to get the requested genre and compare it with the <SELECT> list to add the word SELECTED on the option. So if the requested genre is the same as the option name them make that the SELECTED option. Cheers. Here's a bit of code I made that does not work Code: [Select] <? function selected(){ if ($_REQUEST['genre'] = $name){ echo"SELECTED"; }} ?> Gen <SELECT class="sort" align="right" onChange="window.location.href=this.options[this.selectedIndex].value;"> <option value="<?=$_SERVER['PHP_SELF'];?>" <?$name = ''; selected(); ?>>Any</option> <option value="<?=$_SERVER['PHP_SELF'];?>?genre=Action" <?$name = 'Action'; selected(); ?>>Action</option> <option value="<?=$_SERVER['PHP_SELF'];?>?genre=Adventure" <?$name = 'Adventure'; selected(); ?>>Adventure</option> <option value="<?=$_SERVER['PHP_SELF'];?>?genre=Animation" <?$name = 'Animation'; selected(); ?>>Animation</option> </SELECT> I'm trying to write a select to match a few certain words... $sql = "SELECT * FROM podcasts WHERE `type` = 'podcast' AND recap LIKE 'Men%' AND recap LIKE '%Hockey%' ORDER BY date DESC"; That's what I have so far...which isn't working... I need to match the string "Mens" OR "Men's" with the word "Hockey" BUT...I can't match "Women's" or "Womens" Any idea what I'm doing wrong? The above code only returns 6 results...when it should return nearly 100. Thanks! Hi guys, I'm having a issue with a little bit of coding involving SELECT the problem is I want it to select from the database and say limit it to 5 so basicly it prints 5 results from the database but its only printing 1 result Here is the code i'm using Code: [Select] $q=mysql_query("SELECT * FROM papercontent LIMIT 5",$c); $content=mysql_result($q,0,0); print " <center><table width = '40%' border = '1'><tr><th> <center><u>Latest Announcements</u></center> $content </tr></td></table> "; Thanks Hello dear friends, If i've database table has named as info (id, name, number) and i wanna say select from info where name must has value not empty Code: [Select] select * from info where name='xxxxwhatxxx' i've tired $name and $1 and 1 but all not working how to say where name must has value and not empty example if i've Code: [Select] (id, name, number) values (1, 'manal', '4') (id, name, number) values (2, 'shimaa', '7') (id, name, number) values (3, '', '3') and i wanna say sellect from info where name has value so it shows me only data of id "1" and "2" only thank you so much it would helps me alot to improve myself Code: [Select] id player_id nat nt_caps 13740 28664 97 24 13741 28664 68 0 13742 28664 79 0 16252 42904 15 40 16253 42904 68 0 16254 42904 241 0 That's how my table looks. I want to select the player_id's that have either nt_caps = "0" for every nat OR player_id's that have nt_caps != "0" only for nat = "68". The SQL query I try to use is: SELECT player_id FROM x WHERE nat = '68' AND (nat != '68' AND nt_caps = '0') But then I get player_id '42904' and '28664' because they both have 1 entry that matches the query but I don't want them because they have nt_caps for another nat than nat "68". I hope you understand what I try to achieve. I'm trying to run a readout of a db which runs fine as an individual script. When I embed it in PHP inside an html div container, it bails when it encounters the first ">" and simply outputs the PHP characters from there through the "?>". The rest of the html runs fine before and after. For example, this line echo "<select>"; would output "; and any other php script up to the ?> end, after which it renders html fine. If I run the script as a separate php file, it runs as expected. Any help would be appreciated. Thanks. Code: [Select] $query ="SELECT id,today,uuendus,username FROM u_data WHERE today < '$datex' AND uuendus='YES' ORDER BY id ASC";i want select older then $datex all other code is correct i just want to know is Code: [Select] WHERE today < '$datex' correct to use? ok here's my problem $Sql1 returns two values: 8 and 10 and these numbers get put into a <select>. So far so good. I assign a onchange to it. When i select 8 it makes the changes but when I select 10 nothing happends. I preciate some help. Code: [Select] <?php require("status.php"); require("id.php"); $Link = mysql_connect($Host, $User, $Password); mysql_select_db('sportsportal', $Link); $Sql1 = "select distinct week, (select max(week) from coupons where user='$User') max from coupons where user='$User'"; $Result1 = mysql_query($Sql1, $Link); print "<tr>"; print "<td align=left valign=top> </td>"; print "<td align=left valign=top>"; print "<select name=current_week onchange=window.location='coupon.php?curwk='+this.value>"; while($Row1 = mysql_fetch_array($Result1)){ //if($Row1[week] == $Row1[max]){ //print "<option value='$Row1[week]' selected>Vecka $Row1[week]</option>"; //} else { //print "<option value='$Row1[week]'>Vecka $Row1[week]</option>"; //} print "<option value='$Row1[week]'>Vecka $Row1[week]</option>"; } print "</select>"; print "<p></td>"; print "</tr>"; if(isset($_REQUEST['curwk'])){ $Curwk = $_REQUEST['curwk']; } else { $Curwk = 0; } $Sql = "select home, away, home_score, away_score, winner from coupons where user='$User' and week='$Curwk'"; $Result = mysql_query($Sql, $Link) or die(mysql_error()); while($Row = mysql_fetch_array($Result)){ if(@$Row[home] == @$Row[winner]){ print "<tr>"; print "<td align=left valign=top> </td>"; print "<td align=left valign=top><b>$Row[home]</b> - $Row[away] $Row[home_score]-$Row[away_score]</td>"; print "</tr>"; } else { print "<tr>"; print "<td align=left valign=top> </td>"; print "<td align=left valign=top>$Row[home] - <b>$Row[away]</b> $Row[home_score]-$Row[away_score]</td>"; print "</tr>"; } } mysql_close($Link); ?> hi guys ive just finished this task after hours of head scratching since svg is only really supported good in firefox and opera ive chosen firefox as my browser to view this url www.deansignori.com/phpsvgpie/index.php i do need more help with this task but a different problem (creating select box to call different stylesheet and to change from 2d - 3d i have the code set out so that i can explode any segment or change size of slices or change from 2d-3d but i have to do this manually in the code to render different piecharts im wanting to use 1 but change it using a select box and echo my variable into it basically im unsure of the syntax for this problem psuedo code for style maybe something like if select box value isset onchange stylecolour echo stylecolour if select box value isset onchange stylegrey echo stylegrey and for 3d-2d if select box value isset onchnage format3 echo format3 if select box value isset onchange format2 echo format2 this would be on my index page can anyone advise me please regards Dean Hi everyone! I need to know how to write two $what_services variables in so it looks for both "R" AND "B".. R and B are values within my db table, here's the code: Code: [Select] <?php $what_services = "R"; $query = "SELECT * FROM companies WHERE what_services = '$what_services' ORDER BY approved DESC, company_name ASC"; $result = mysql_query($query); ?> iv'e tried the following but have gotten undesired results: two what services like so; $what_services = "R"; $what_services = "B"; separating with comma's; $what_services = "R, B"; Using AND; $what_services = "R AND B"; None of which works, what is the correct way to write this? Thanks Hi, what I want to figure out is for instance a person has registered with their country e.g. England. Now if I echo the country in a select box giving the person an option to change their country and Showing the person which currently they have selected already. The select box shows two England`s to select from. Could some one tell me how can I have one of each country and echo their already selected country from the database. I don't know how to explain any better what I am after but just basically there are two Englands showing one which is already selected (echoing from the mysql database) and one is already in the select box. Any help is much appreciated thank you. Hello,
i am starting to freak out ... i am trying to make a select but it dont want to work.
So what do i have:
i have 2 Tables
table 1: customer (contains the name) (fieldname: name)
table 2: bookings (contains the name from customer) (fieldname: belegung)
in table 2 there are multiple lines with lets say 10 customer xyz and 3 customer xxx
in table 1 every customer is only once and it includes 5 customer
my output i want to have now is a group by where i have the customer in column 1 and the count(*) in column 2
so in my case
customer xyz - 10
customer xxx - 3
customer 3 - 0
customer 4 - 0
customer 5 - 0
i only manage to group them, so i can see it like
customer xyz - 10
customer xxx - 3
customer 3 - 1
customer 4 - 1
customer 5 - 1
as it goes on the count(*) from table 1
please if someone could help me i would be pleased
Hi, I'm not quite sure how to do this, so i thought i'd ask you guys from some assistance. Basically i am inserting Author's into a table successfully using an array. The reason for this is that i have multiple authors being added and there is no limit as to how many. An example of what i mean can be seen he http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/test.html You can click on "Add author" to add however many necessary.. Anyway, i have got the insert working, however when i edit i want to be able to see all the authors that have been added but obviously i don't know how many there are.. Typically i would like to see something like this: http://www.prima.cse.salford.ac.uk:8080/~ibrarhussain/edit.jpg So i would click on an edit link and it would pre populate the text boxes. I don't have a problem with doing this, but how can i show the correct amount of input textboxes based on how many authors exist for that specific record? Can someone offer some advice please? The input elements are like so: Quote <input type="text" name="author[]" id="author1"/> <input type="text" name="author[]" id="author2"/> <input type="text" name="author[]" id="author3"/> ... ... ... <input type="text" name="author[]" id="author10"/> Some records may have 1 author some may have 10, so how can i do this? Thanks again.. Hi, I'm trying to make a 3 page registration form. On the 3rd page I want it to echo back all the options they have selected. I can get the input type to work but having problems with the selects. First Page Code: [Select] <form action="choose.password.php" method="post"> eMail: <input type="text" name="eMail" /><br /> Forename: <input type="text" name="fname" /><br /> Surname: <input type="text" name="lname" /><br /> Date of Birth: <input type="text" name="dob" /><br /> Gender: <select name="gender"> <option value="male">Male</option> <option value="female">Female</option> </select> <br /> I am not a lawyer: <input type="checkbox" name="lawyer" value="lawyer"> <br /> <br /> <input type="submit" value="Next" /> </form> Second Page Code: [Select] <form action="confirm.details.php" method="post"> <p>email address: <?php echo $_POST["eMail"]; ?></p> <p>password: <input type="password" name="eMail" /></p> <p>Confirm Password: <input type="password" name="eMail" /></p> <p>Hint: <input type="text" name="hint" /></p> <p>My email is correct, I am happy to be sent occassional emails, and i am not a family lawyer. <input type="checkbox" name="lawyer" value="lawyer"></p> <input type="hidden" name="fname" value="<?php echo ($_POST["fname"]); ?>" /> <input type="hidden" name="eMail" value="<?php echo ($_POST["eMail"]); ?>" /> <input type="hidden" name="lname" value="<?php echo ($_POST["lname"]); ?>" /> <input type="hidden" name="dob" value="<?php echo ($_POST["dob"]); ?>" /> <select style="display:none;" name="gender" <?php echo ($_POST["gender"]); ?> /> <p><input type="submit" value="Next" /></p> Third page Code: [Select] <p>Please confirm your details are correct to register.</p> <p>Email Address: <?php echo $_POST["eMail"]; ?> <p>Forename: <?php echo $_POST["fname"]; ?></p> <p>Surname: <?php echo $_POST["lname"]; ?></p> <p>Date of Birth: <?php echo $_POST["dob"]; ?></p> <p>Gender: <?php echo $_POST["gender"]; ?></p> How can I make the select work and echo it back on the third page? Thanks Hi I have some website code that has worked fine up to now. I enter a day / month and / year. I tried to change the txt box for the day into a drop down list. and the submission $_POST fails. This works <input style="text-align:right;" type="text" size="1" maxlength="2" name="DD_Balance" value="<?=$_SESSION["DD_Balance"]?>"> /
This doesn't
<select name="DD_Balance" style="width:40px">
Confused as the names of the objects are the same. Also view text is all screwed up on several lines not underneath each other. Hi guys, I'm trying to do make this code so that IF a user owns a property (in this code a bulletfactory) then the BF CP Shows up... Here's the code so far..... Code: [Select] <?php session_start(); include_once"includes/db_connect.php"; include_once"includes/functions.php"; logincheck(); $username=$_SESSION['username']; $query=mysql_query("SELECT * FROM users WHERE username='$username'"); $fetch=mysql_fetch_object($query); $query_bf=mysql_query("SELECT * FROM bf WHERE location='England, Japan, Colombia, USA, Russia, Italy, Turkey'"); $fetch_bf=mysql_fetch_object($query_bf); if (strtolower($fetch_bf->owner) == (strtolower($fetch->username))){ require_once"bulletCP.php"; exit(); } ?> |