PHP MySql select drop box with if statement and alert box [closed] - php

This post was returned to Super User. It is not currently accepting new answers or interactions. Learn more
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 29 days ago.
I have a select option with data taken from the staff table. I want a notification to appear when I select data from the table. the notification is like this "the resident is not registered in this rt". for the staff table itself there are already 11 rt.
Here I attach my code:
<div class="form-group form-group-sm">
<label class=" control-label col-sm-3" control-label">Meneruskan Ke</label>
<div class="col-sm-3">
<select name="cbjenis" id="cbjenis"><option disabled selected> Pilih </option><?php $sql=mysqli_query($koneksi,"SELECT * FROM tb_staff"); while($data=mysqli_fetch_array($sql)) {?><option value="<?=$data['id_staff']?>"><?=$data['nama_staff']?></option><?php } ?></select></div></div>
Table:

Related

How to retrieve multiple columns using pluck on form select? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I'm using pluck to retrieve some columns (name & id) and populate on form select. This is my current solution
Controller
$shops = DB::table('shops')->pluck('shop_name', 'id');
return View::make('index')->with('shops', $shops)
View
{{ Form::select('id', $shops, null, ['class' => 'form-control']) }}
Output
<select class="form-control" name="id">
<option value="1">JDon</option>
<option value="2">Watsons</option>
</select>
How about if I want to retrieve 3 columns (name, address & id) and I want to show to the user the shop name & address?
Try this :
$shops = DB::table('shops')
->select(DB::raw("CONCAT(shop_name,' ',address) AS shop_full_name"),'id')
->pluck('shop_full_name', 'id');

SQL Query Select That User Don't Have The Products [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Im trying to make a feature called "Edit Profile User" this
so in this feature im as Admin that can Edit User's Profile such as Name, username , DOB, etc.
in this feature we also can edit/Assign Product to this user. Example
User A have product :
1. Shampoo
2. Soap
3. Toothpick
and in server we've more than 3 product which are : Shampoo, Soap, Toothpick, Sponge, and Towel (5 items)
so the problem is : how to show the items that User have and automatically selected in select option, and also show the product that user didnt have / still available in server ?
so the example is :
User A Product :
1. Shampoo (selected)
2. Soap (selected)
3. Toothpick (selected)
4. Sponge
5. Towel
im still confuse and no idea , already a week searching on google .
and i use Chosen from harvest with multiple select
here's the source : https://harvesthq.github.io/chosen/
can anybody help me figure it out this problem ? im so stressed
*and this project based in Laravel
<form action="process.php" method="POST">
<select name="items[]" class="form-control">
<option value="Ketchup" selected>Ketchup</option>
<option value="Mustard">Mustard</option>
</select>
<input type="submit" value="submit">
</form>
Then in process.php
$items = $_POST['items'];
foreach ($items as $item) {
echo '$item' . <br>;
}
This will show the items you've selected

How to make for each user, documents start by id 1? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I need to make database for users and every user have documents which will line up in this order for
user1(document1 have id 1, documnet2 have id 2, documnet3 have id 3, etc...)
user2(document1 have id 1, documnet2 have id 2, documnet3 have id 3, etc...)
?
Create two tables to accomplish this.
The first table should contain your users. Example:
|id|username|password|
|1|user1|1234|
|2|user2|1234|
Then create a second table containing your documents
|id|document|owner_id|document_id|
|1|adocument.doc|1|1|
|2|anotherdoc.doc|1|2|
|3|adocument.doc|2|1|
|4|anotherdoc.dco|2|2|
In this example you see that the documents in the document-table point to a owner_id. This should be the id of the user in the users table.
This is just to head you in a direction for a solution to your question. We cant write the entire code for you, so start googling a bit on mysql.

How to create drop down menu [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
i'm trying to create dropdown menu, this drop down menu is about name of countries, so when the user for example choose country A then all the posts that are associated with country A will be displayed.
So my question is do i need to create a separate PHP file for every country in order to get the posts that are associated to a particular country?
No you would create your dropdown as usual with
<select name="myCountry">
<option>Country A</option>
<option>Country B</option>
<option>etc lol</option>
</select>
Then have your form point to your PHP processing file, and in there you would do something like.
$selectedCounty = $_GET['myCountry']; //This assigns the selected value from that country dropdown into a usable variable.
Then u query the database.
Lets assume you have a database table called "countries" and a column with the countries listed called "myCountries".
$selectCountryQS = SELECT * FROM countries WHERE myCountries = '$selectedCountry';
Then put it into action
$selectCountryDoIt = mysqli_query('connection variable here', $selectCountryQS ) or die('error mssg'. mysqli_error(conection var here));
Then set a while loop that will grab ALL the posts data that you wanted.
while($row = mysqli_fetch_array($selectCountryDoIt)){
echo $row[' your column data to display here'];
}
This will give you what you need.
Hope this helps. Good luck

How to join 2 tables & display them correctly? [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
http://img293.imageshack.us/img293/857/tablez.jpg
Here is a picture of the 2 tables.
The mybb_users table is the table that has the users that signed up for the forum.
The mybb_userfields is the table that contain custom profile field data that they are able to customize & change in their profile.
Now, all I want to do is display all users in rows with the custom profile field data that they provided in their profile(which is in the mybb_userfields table)
How can I display these fields correctly together?
For instance, p0gz is a male,lives in AZ,he owns a 360,does not know his bandwidth & Flip Side Phoenix is his team.
How can it just be like "p0gz-male-az-360-dont know-flipside phoenix" in a row~???
This looks for me like an ordinary LEFT JOIN
SELECT * FROM mybb_users
LEFT JOIN mybb_userfields
ON (mybb_users.uid = mybb_userfields.ufid)
WHERE username = 'p0gz'
This should display every row of the user p0gz

Categories