Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

dede

Members
  • Joined

  • Last visited

Everything posted by dede

  1. thanks for the tip ELITE. my problem is to loop through all checkboxes, and for each checked, populate a separate record in a database. actually i don't know how to recognize the which box is checked, and put the appropriate value in db. thanks again
  2. dede replied to Skysurge's topic in Server Side
    Skysurge, your idea is great, and sharing your knowledge with us will help us for sure
  3. Hi to all I need help for this problem that i'm trying to solve for a while (i'm new in PHP). I have a form with several checkboxes which values are pulled from a database. I managed to display them in the form, assign an appropriate value to each, but cannot insert their values into other database. Here's the code: <form id="form1" name="form1" method="post" action=""> <?php $info_id=$_GET['info_id']; $kv_dodatoci=mysql_query("SELECT * FROM `dodatoci`") or die('ERROR DISPLAYING: '.mysql_error()); while($kol=mysql_fetch_array($kv_dodatoci)){ $id_dodatoci=$kol['id_dodatoci']; $mk=$kol['mk']; echo '<input type="checkbox" name="id_dodatoci[]" id="id_dodatoci" value="'.$id_dodatoci.'" />'; echo '<label for="'.$id_dodatoci.'">'.$mk.'</label><br />'; } ?> <input type="hidden" value="<?=$info_id?>" name="info_id" /> <input name="insert_info" type="submit" value="Insert Additional info" /> </form> <?php if(isset($_POST['insert_info']) && is_array($id_dodatoci)){ echo $id_dodatoci.'<br />'; echo $mk.'<br />'; // --- Guess here's the problem ----- // foreach($_POST['id_dodatoci'] as $dodatok){ $dodatok_kv=mysql_query("INSERT INTO `dodatoci_hotel`(id_dodatoci,info_id) VALUES ('$dodatok','$info_id')") or die('ERROR INSERTING: '.mysql_error()); } } ?> I need to insert a new record in the database for each checked checkbox, so i guess the problem lies in the foreach loop. I hope someone can help me solve this or give me some guideline. Thanks in advance.
  4. well i have done that, but the problem is in processing all those forms each one as a separate record with a single submit button. i've tried with two 'for' loops, one for the form, and on e for the query, and first it was working ok, but now seeems that it stops inserting values in the database. i'm getting crazy with this. thanks
  5. Hi to all I have a problem with putting data in db, with dynamically created form, actually dynamically created "n" number of times of the same form. In details, i have a form where the user inserts the number of rooms, and when the submit button is pressed, the form for inserting info for each room separately is displayed n times, where n is the number of the rooms which was entered in the previous form. The code (number_of_rooms.php): $hotel_id=mysql_insert_id(); //the id of the hotel from previous query </p> <form id="form1" name="form1" method="post" action="rooms_details.php"> <label for="number_of_rooms">Total room number</label> <input type="text" name="number_of_rooms" id="number_of_rooms" /> <input name="hotel_id" type="hidden" value="<?php echo $hotel_id; ?>" /> <p> <input type="submit" name="insert_room_number" id="insert_room_number" value="Insert Total Room Number" /> </p> </form> Code from room_details.php : <form id="form1" name="form1" method="post" action="room_details.php?number_of_rooms=$number_of_rooms"> <?php for($i=1;$i<=$number_of_rooms;$i++){ ?> <fieldset><legend>Room Number <?php echo $i; ?></legend> <label for="room_number">Real Room Number</label> <input type="text" name="room_number<?php echo $i; ?>" id="_room_number" /> <br /> <label for="room_type">Room Type</label> <input type="text" name="room_type<?php echo $i; ?>" id="room_type" /> <br /> <label for="room_name">Room Name</label> <input type="text" name="room_name<?php echo $i; ?>" id="room_name" /> <input name="hotel_id" type="hidden" value="<?php echo $hotel_id; ?>" /> <input name="number_of_rooms" type="hidden" value="<?php echo $number_of_rooms; ?>" /> </fieldset> <?php } ?> <input type="submit" name="vnesi_site_sobi" id="insert_all_room_data" value="Insert data for all rooms" /> </form> So far works fine, since if i enter the number 3 in the number_of_rooms.php form, I get the same form three times for inserting room details in room_details.php , and each form has same name of the fields incremented by the $i parameter in the for loop. For example, with 3 rooms, i have room_number1 for the Real Room Number field in the first form, room_number2 in the second form. room_number3 in the third form, etc. What i'm trying to achieve is to to put all the forms in the room_details.php file in the same form, so the submission button is clicked only once, and submits all the data of each form in the database separately as a new record, bypassing the the need to push the submit button for each room separately. This is because if i have for example 20 or 50 rooms, entering details one by one and pushing the submit button for each room is tedious. For this, i tried with for loop, but with various combination of it i only succeed to insert only the last form data, and NOT all of them as separate record. I know it looks like a big mess, but i'm trying to solve this for 2-3 days and haven't managed to find the appropriate for loop that will insert each form as a separate record with a single click. Does anyone have any idea? Thanks in advance
  6. dede replied to dede's topic in Server Side
    Yes, exactly this was my problem, and now works fine. As i mentioned in the first post, i wasn't sure if WHERE clause can be used with INSERT, and now jamest has cleared this confusion to me. Thanks to everybody for trying to help me.
  7. dede replied to dede's topic in Server Side
    Thanks pat24 for this. I've tried, and the same error occurs. I guess the problem is elsewhere. Maybe if I clarify what i'm trying to do, you'll be able to help me. So, i'm trying to make a simple booking application, in which the guest first inserts the booking details in a form, and then the personal details. For this i have bookings and guests table. Guests table has PRIMARY KEY guest_number, and a FOREIGN KEY - booking_id, which is used to identify (connect) the booking info with the guest info. The bookings table has booking_id as PRIMARY KEY, and guest_number as FOREIGN KEY, in which the primary key from the guests table should be inserted. Since the booking form is submitted first, i cannot have the guest_id value until the the guests table is populated (in the next form), so the problem is how to insert the guest_number from the guests table into the previously inserted record in the bookings table. Maybe a complete redesign in the workflow could help, something like inserting guests' info first and then booking details, or maybe i should make another intermediate MySQL table, in which the booking_id and the guest_number pairs would be stored. Any idea? Thanks
  8. dede replied to dede's topic in Server Side
    Thanks ErisDS for pointing that (the missing single quote in the '$guest_id). Anyway, with adding the single quote, i still get the same error: Guest ID Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE booking_id=12' at line 1 and yet don't have an idea why. I have the booking_id and the guest_number values that are identical to those inserted into the database from previous queries, and still cannot implement the SQL query to insert the guest_number into the bookings table.
  9. Hi to all I need help, cause i'm stuck into this. I have Bookings and Guests table. Bookings table has booking_id,hotel_id and guest_number, while the Guests table has: guest_number,name and booking_id as columns. So, first i'm entering the booking information in a form for booking, in which i have a booking_id hidden field passed to the query that inserts info in the Guests table. In the Guests form which inserts info into the Guests table, i have to extract the guest_number (PRIMARY KEY of Guests table) and put it back in the Bookings table as a FOREIGN KEY (bookings.guest_number), but in the previously entered booking record. So, to get the value from the PRIMARY KEY of the Guests table i'm using the mysql_insert_id() function, assign that value to other variable, and use it in query, while for identifying the previous booking record i'm using thte passed booking id from the hidden field from the previous form (booking_id). I know it's a mess, but now i cannot explain it better. Here's the code: //////Query for inserting into Guests table///////// $qv_guest="INSERT INTO guests(name,surname,city,state,email,booking_id) VALUES('$name','$surname','$city','$state','$email','$booking_id')"; $res_guest=mysql_query($qv_guest) or die("Guest Insert Error: ".mysql_error()); ///Query for inserting the guest_number into the previous Bookings record $guest_id=mysql_insert_id(); $qv_guest_id="INSERT INTO bookings(guest_number) VALUES('$guest_id) WHERE booking_id=$booking_id"; //this is where the Error is!!!! $res_guest_id=mysql_query($qv_guest_id) or die("Guest ID Error: ".mysql_error()); This is the error message i get: Guest ID Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1) WHERE booking_id=7' at line 1 Since i'm a beginner in PHP and especially in MySQL, i guess that isn't allowed to use WHERE clause in INSERT statement into the MySQL. So, is there a way to insert the PRIMARY KEY ID of the previous INSERT query into other table as FOREIGN KEY? Thanks in advance
  10. just a thought: won't be better if the second person is restricted to log in if the first one is already logged?
  11. thanks for this, guys. both mysql_fetch_row and mysql_result gives me the name of the city selected in the drop down, which is what i wanted to achieve. thanks again the only problem is that when i use single quotes in the query it gives an SQL error, which is pretty strange since as much as i know, using them in a query prevents (together with mysql_real_escape_string) from SQL injection
  12. just a little hint about this great piece of code: i think that using preg_match instead of eregi for server validation is faster (although in this situation won't make any difference), but in the next PHP 6, eregi function will be completely removed
  13. Hi to all I've trying to solve this issue for a while, and cannot find where the problem is. This is what i'm stuck into: I have a simple database table named 'cities' with two rows: 'id_city' and 'city_name'. I'm trying to make a search form, in which the name of the cities are displayed in a drop down. So search.php is something like this: <?php mysql_select_db(city_app,$con); $qry="SELECT * FROM `cities` ORDER BY `city_name` ASC"; $res=mysql_query($qry) or die(mysql_error()); ?> <form action="search_results.php" method="get"> <select name="city" > <option value="">---Choose a city---</option> <?php while($row=mysql_fetch_assoc($res)){ echo '<option value="'.$row['id_city'].'">'.$row['city_name'].'</option>'; } ?> <input type="submit" name="submit" value="Submit" /> </form> As you can see, the form passes the value id_city to the search_results.php, where the actual problem is ( i guess ). Now the search_results.php: <?php if(isset($_GET['submit'])){ $city_name=$_GET['city']; echo $city_name // gives me the value of id_city $kv="SELECT `city_name` FROM `cities` WHERE `id_city`=`$city_name`"; $rez=mysql_query($kv) or die(mysql_error()); echo $rez; } ?> What I'm trying to do is to diplay the city name instead the value of the id_city, but cannot figure how. If I echo the $city_name, i get the value of the id_city identical to echo '<option value="'.$row['id_city'].'">....... in the search form. Can anyone guide me to this noobish problem i have? Thanks in advance.
  14. Hi from dede (that's me ). Trying to learn some php coding, so I'll be sticking there ....

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.