-
Posts
24,605 -
Joined
-
Last visited
-
Days Won
830
Everything posted by Barand
-
That is way the two types of join are meant to work. A INNER JOIN B returns only rows where there is a match on the join condition in both A and B A LEFT JOIN B returns all rows from A with any matching data from B. If there is no matching B row then columns from B contain NULL
-
I'm stuck with access.mdb need help with this code
Barand replied to dlbDennis's topic in PHP Coding Help
If you are expecting only one row then you already fetched it with $count=odbc_fetch_array($result); By the time you get to the while() loop there are no more left to fetch. -
Is there a way to duplicate divs and increment them?
Barand replied to imgrooot's topic in PHP Coding Help
Use a for() loop, and make $page an array. -
Erm, if it really were egregious then you wouldn't miss it
-
Not pretty, but it works (I think). You can use sub-elements of this solution to break down that single column into three columns in your redesigned table, viz. prestring quantity poststring Data mysql> select * from tablea; +----+-------------------------------+ | id | col_a | +----+-------------------------------+ | 1 | Lorem ipsum = 88 dolor | | 2 | De profundis = 102 clamavi | | 3 | matutina usque ad = 55 noctem | +----+-------------------------------+ Query and results: UPDATE tablea SET col_a = CONCAT ( SUBSTRING_INDEX(col_a, '=', 1) , ' = ' , SUBSTRING_INDEX(TRIM(SUBSTRING_INDEX(col_a, '=', -1)), ' ', 1) + 1500 , ' ' , SUBSTRING_INDEX(TRIM(SUBSTRING_INDEX(col_a, '=', -1)), ' ', -1) ) ; mysql> select * from tablea; +----+----------------------------------+ | id | col_a | +----+----------------------------------+ | 1 | Lorem ipsum = 1588 dolor | | 2 | De profundis = 1602 clamavi | | 3 | matutina usque ad = 1555 noctem | +----+----------------------------------+ 3 rows in set (0.00 sec)
-
This is strange. It won't insert "0" option value into table.
Barand replied to imgrooot's topic in PHP Coding Help
All you have shown us is a single line of incorrect code and I pointed out what is wrong with that code. You could try <option value="0" <?php if ($_POST['special'] === '0') echo 'selected'; ?> >None</option> On the basis of a single line I can not and will not comment on an application solution, as I have no idea what the significance of the "0" versus "" is in the overall context. But your proposed alternative sounds wrong. -
SQL/PHP: Using a 10 row form to update 10 rows WHERE a column =...
Barand replied to alturic's topic in PHP Coding Help
-
SQL/PHP: Using a 10 row form to update 10 rows WHERE a column =...
Barand replied to alturic's topic in PHP Coding Help
Create a table of areas and another for zipcodes. In the zipcode table, include the area_id to group the zips into the areas. Create a forecast for the area. Select which zipcodes that forecast applies to and save. If it isn't all zips in the area then create another forecast and select zips. Repeat as necessary. +-------------+ +-------------+ | area | | zipcode | +-------------+ +-------------+ | area_id |------------------------+ | zip | | name | +-----------------<| area_id | +-------------+ +-------------+ | | | | | | | +-------------+ +---------------+ | | | forecast | | applies_to | | | +-------------+ +---------------+ | | | forecast_id |----------<| forecast_id | | +---<| area_id | | zip |>---------+ | date | +---------------+ | text | +-------------+ -
I'd make a couple of changes move the WHERE condition to the JOIN condition for the answer table use a LEFT join for the txtanswer table SELECT question.*, question_options.*, answer.*,txtanswer.* FROM question LEFT JOIN question_options ON question.question_id = question_options.question_id LEFT JOIN answer ON answer.option_id = question_options.qtn_option_id AND answer.empid = 'EMP8969' LEFT JOIN txtanswer ON txtanswer.qtn_option_id= question_options.qtn_option_id And don't use *s in the SELECT, specify the required fields.
-
Pivot Table or Cross Tab in PHP using MYSQL for attendance
Barand replied to akshayhomkar's topic in PHP Coding Help
It sets the value after checking if it has changed $curname = $sn; pseudocode: set curname to empty while fetch next record if name value changed if we have a current value output the data for the current name endif set curname to new name value endif process the new record endwhile -
Pivot Table or Cross Tab in PHP using MYSQL for attendance
Barand replied to akshayhomkar's topic in PHP Coding Help
Hi Newbie, You are also incapable of working out that my name in my posts is in exactly the same place as your name is in your posts. (Strange, but true.) $curname stores the current name. I then test the value of the new name against to see if it has changed, and then store the new value in $curname. -
Not necessarily - you just had to read it
-
http://lmgtfy.com/?q=addthis
-
Output post code from MySQL, create Google Map with marker
Barand replied to ade234uk's topic in PHP Coding Help
see https://developers.google.com/maps/documentation/javascript/examples/marker-simple -
The values are the wrong way round. You are putting the $btcaddy into the ip_address column
-
If you are intent on using a text file then store it as json encoded data. Take advantage of the fact that an array key must be unique and make the BTC the key. To get the current submissions and put in an array $submissions = json_decode(file_get_contents('btcs.json'), true); to add a new submission if (isset($submissions[$btc]) { // error - already exists! } else { $submissions[$btc] = [ 'username' => $username , 'ip' => $ip ]; } to save the data, reverse the first code file_put_contents('btcs.json', json_encode($submissions)); However, you really should get to grips with using a database. It has so many advantages and it's a move you'll need to make sometime.
-
... or add a UNIQUE key to the field to make it impossible to add the same one twice
-
You don't even need a loop. You can check the whole array with a single statement if ($input != str_replace($myArray,'', $input) ) { echo "Contains an existing value"; }
-
Code is not working trying to login using SQL SERVER
Barand replied to TStyles's topic in PHP Coding Help
You have only the database name -
Using an aggregation function (SUM(), COUNT() etc) without specifying a GROUP BY column(s) will return a single row containing the aggregate for the whole selection. Values for the other non-aggregated selected columns are indeterminate (although usually from the first record in the set.
-
looks like data is array to me $obj = (object)[ 'name' => 'my name', 'data' => [2,4,6]]; print_r($obj); /* results ******************** stdClass Object ( [name] => my name [data] => Array ( [0] => 2 [1] => 4 [2] => 6 ) ) */
-
$obj = (object)[ 'name' => 'my name', 'data' => [2,4,6]];
-
How/What is the correct way to create a function for MS SQL Queries.
Barand replied to kat35601's topic in PHP Coding Help
Translating the above to sqlsrv dialect WHERE DATEPART(yyyy, datefield) = targetyear AND DATEPART(mm, datefield) = targetmonth -
looping results from query and limit amount per row
Barand replied to jacko_162's topic in PHP Coding Help
Easiest way is to read the results into an array and then use array_chunk() with a chunk size of 5. Output each chunk as a row.