Jump to content

rwigs

Members
  • Posts

    11
  • Joined

  • Last visited

rwigs's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ok, that makes sense. Since I won't the unique ID for the event record until it is created, I would do an AFTER trigger that could take the values entered in the city field and put them into the EventCities table with the eventID. Then when selecting from the events table join on the eventid columns. Is that what you are thinking?
  2. Ok, so I have been asked to help with an existing website. They have a form that users can submit information. One of the fields used to be a radio button selection but they changed it to checkboxes so that the user could select more than one option. They did it right as far as the checkboxes work and multiple selections get entered into the field in the database in a comma separated format. So they thought they were good and couldn't figure out why they can no longer select from the database where the field had one of the selections that they were looking for. What I mean is something like this: The data from the insert from the checkboxes would put something like this in the field: Tucson, Phoenix, Mesa And they were running another function that was saying: select * from eventstable where city = 'Tucson' but it would not select the record. To you and I that makes sense, but I had a hard time explaining to them why it doesn't work. So that leads me to them asking for help. So I am looking at a couple of different options here to address this: 1. Change the insert process to loop through each of the values in the checkboxes, inserting a record for each one with all the other data being the same, only entering one value for city per record. 2. Tackle it on the other end and create a triger that will go after each insert, that will see if there was more than one value entered in the city field and break that record into multiple records, having the same effect as the other option. I have more experince working in SQL than PHP, so the first option is less attractive for me to tackle. But I don't want to let my fear of what I'm not used to prevent me from doing something that would be easy if I just learned how to do it. Opinions?
  3. Using stripslashes in the output, rather than the query, did exactly what I needed to do. Thanks!
  4. I'm not involved with the insertion part, that was done before I got asked to step into this. All I am trying to do is select the data to display. It works fine but just shows the \ before any apostrophe, so I am trying to figure out how to strip that out. Still can't get it to work, getting errors in my syntax.
  5. @NotionCommotion, I was not sure which one to put it in either. It could go either way. But, I can get the query to work in MySQLWorkbench when accessing the database directly, but I cannot get it to work when using it in the PHP page. So I went with the PHP forum. As for why they are in there, I am not sure. This is someone else's project that I have been asked to help out with because "You're an IT guy, you should be able to do this, right?"
  6. Thanks for the reply. Unfortunately, I am still getting an error message for my syntax. Here is the complete query, if it makes a difference: $qry = "SELECT Name, CONCAT_WS(', ', replace(location,'\\',''), address, city, state, zip) as location, Details, date_format(date, '%W, %M %e') as date , date as date2 , Time_Start , Category , Papers FROM Events where id in ('".$events."') order by date2 , time_start";
  7. I am using a query to pull from MySQL. In my PHP code, it looks like this: $qry = "SELECT Name, CONCAT_WS(', ', location, address, city, state, zip) as location, Details... But some of the records have a backslash (\) in the location in front of an apostrophe, so I am trying to use REPLACE to get rid of it. For example, the value in location might be 'Mom\'s house' and I want to just select it as 'Mom's house'. But I am not having any luck with this: $qry = "SELECT Name, CONCAT_WS(', ', replace(location,'\',''), address, city, state, zip) as location, Details Anyone know how to make that work?
  8. I have a page form that allows users to enter some information, attach a file, and submit it into my sql. The page works fine. After attempting the sql insert, I have this code: $result = mysqli_query($db_conx, $sql ); if($result){ $success_msg = "Thanks for your submission.".$upload_files."<a href='index.php'>Home</a> || <a href='buyad.php'>Buy</a>"; } else { $errors[] = "<p style='color:red'>There was an error saving your submission. Please contact us.</p>"; } So when it is successful, I get the success message at the top of the screen. What I want is to have a pop up window of a defined size that gives the message and the two links. As well as if there is an error, that should be in the pop up window. Now, I have read that pop up windows are a dying trend because most people block them and a good way to go might be a jquery solution. Any input on how to do that? Thanks!
  9. Thanks! The simplest things... I hadn't thought to check error logs because I didn't really know how to check them on local machine. But I found them and found that I had an undefined class in index.php. That fixes one problem, now on to the next (which I will make a new post for). Thanks again!
  10. When I have the following line in my php file I only get HTTP 500 error when trying to view the page: require_once('dbConnection.php'); The contents of dbConnection.php are: <?php /* Database connection information */ $gaSql['user'] = "myuser"; $gaSql['password'] = "mypassword"; $gaSql['db'] = "mydatabase"; $gaSql['server'] = "localhost"; $db_conx = mysqli_connect( $gaSql['server'], $gaSql['user'], $gaSql['password'],$gaSql['db'] ) or die( 'Could not open connection to server' ); // Evaluate the connection if (mysqli_connect_errno()) { echo mysqli_connect_error(); exit(); } ?> If I comment out the require_once line then the page works (well, it won't do the database connection parts, but I get the form and not HTTP 500. Any reason why this shouldn't work?
  11. Hi all. New here, and new to php. I have been working on a project and had some good success. I am using the array_chunk_vertical function and it works great. Now I need it to do a little bit more and I can't figure it out. I have attached my working file for review. But basically, this is what I am working on. Here is my code: <?php function array_chunk_vertical($input, $size, $preserve_keys = false, $size_is_horizontal = true) { $chunks = array(); if ($size_is_horizontal) { $chunk_count = ceil(count($input) / $size); } else { $chunk_count = $size; } for ($chunk_index = 0; $chunk_index < $chunk_count; $chunk_index++) { $chunks[] = array(); } $chunk_index = 0; foreach ($input as $key => $value) { if ($preserve_keys) { $chunks[$chunk_index][$key] = $value; } else { $chunks[$chunk_index][] = $value; } if (++$chunk_index == $chunk_count) { $chunk_index = 0; } } return $chunks; } $values = array(1,2,3,4,5,6,7,8,9,10,11,12); $rows = array_chunk_vertical($values, 6); print "<table>\n"; foreach ($rows as $row) { print "<tr>\n"; foreach ($row as $value) { print "<td>" . $value . "</td>\n"; } print "</tr>\n"; } print "</table>\n"; ?> What I have will produce this result (using 6 columns in the function): 1 3 5 7 9 11 2 4 6 8 10 12 What I would like to be able to do is add another dimension and group them but the second dimension, like an employee number. So say I have the following data: employee# value1 value2 value3 value4 value5 value6 value7 value8 value9 value10 value11 value12 101 1 2 3 4 5 6 7 8 9 10 11 12 202 2 4 6 8 10 12 14 16 18 20 22 24 I want the result to be (still using 6 columns): 101 5 10 4 14 24 1 6 11 6 16 2 7 12 8 18 3 8 202 10 20 4 9 2 12 22 Any help for this newbie would be greatly appreciated! columns.php
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.