-
Posts
24,563 -
Joined
-
Last visited
-
Days Won
822
Everything posted by Barand
-
Putting an array in to a CSV using fputcsv
Barand replied to Kristoff1875's topic in PHP Coding Help
Nonsense!. You can access any bits of a datetime field that you need. EG mysql> SELECT dob FROM date_sample; +---------------------+ | dob | +---------------------+ | 2014-09-11 20:57:22 | +---------------------+ mysql> SELECT YEAR(dob) as year FROM date_sample; +------+ | year | +------+ | 2014 | +------+ mysql> SELECT MONTH(dob) as month FROM date_sample; +-------+ | month | +-------+ | 9 | +-------+ mysql> SELECT DAY(dob) as day FROM date_sample; +------+ | day | +------+ | 11 | +------+ mysql> SELECT DATE_FORMAT(dob, '%b %d') as birthday FROM date_sample; +----------+ | birthday | +----------+ | Sep 11 | +----------+ -
Putting an array in to a CSV using fputcsv
Barand replied to Kristoff1875's topic in PHP Coding Help
As a space-saver it isn't much of an idea either A DATETIME field in a table occupies 8 bytes whereas $serialized_date = 'a:3:{i:0;s:2:"03";i:1;s:2:"02";i:2;s:4:"1986";}'; echo strlen($serialized_date); #---> 47 39 wasted bytes! -
Putting an array in to a CSV using fputcsv
Barand replied to Kristoff1875's topic in PHP Coding Help
You'll have to unserialize() then join() to get a string value. Why are a you using a relational database to store data in a manner that prevents you from ever using it as a relation database? I recommend you read up data normalization and relational database design. -
Output an HTML anchor tag with a link to the file. echo "<a href='path/to/file'>View</a>";
-
Having a form insert the data in the database.
Barand replied to laflair13's topic in PHP Coding Help
You are connecting with mysql_connect() then using mysqli_query(). You need a mysqli connection, you cannot mix the two. -
Check your array is as it should be echo '<pre>',print_r($opts, true),'</pre>'; For example, is there a "/" missing from the URL item?
-
echo urldecode("Galaxy+Universe+Admin"); #--> Galaxy Universe Admin
-
Two Input Forms - One Based Upon Input to the Other
Barand replied to nshaw's topic in PHP Coding Help
The array code is perfectly valid. If you want an indexed array to start at 1 instead of 0 $array = array( 1 => "a", "b", "c", "d", ); echo '<pre>',print_r($array, true),'</pre>'; RESULT Array ( [1] => a [2] => b [3] => c [4] => d ) See PHP manual http://php.net/manual/en/language.types.array.php example #5 -
Replacing the current <script> with this in the code I posted in your other thread will do it <script type="text/javascript"> //******************************************** // Create the on-click function for each // clickable cell (class = day) // to resubmit the page with clicked date //******************************************** <?php if (isset($_GET['date'])) { echo "var formvis = \"visible\";" ; } else { echo "var formvis = \"hidden\";" ; } ?> $().ready(function(){ $(".form").css("visibility",formvis); $(".day").click(function(){ location.href="?date="+$(this).attr("id"); }) }) </script>
-
does this help? http://www.firstdata.com/downloads/marketing-merchant/fdgg-web-service-api-v3.pdf
-
Then what are you sending to Linkpoint, if it requires an xml string?
-
If I understand right, the second block above should be like the third, not using POSTs that don't exist.
-
Sorry, it would come from the "business" input. $id = intval($_POST['business']);
-
Check the query that is actually submitted by echoing the final SQL string that is executed echo "select count(*) as t from utilizador".$se; It helps debugging if you always build the sql as a string variable first then execute that.
-
I grovel on my knees, Sir. Please accept my most humble apologies for missing your comments and just reading your code.
-
Let me get it straight. You have a page that does this $_SESSION['name'] = $_POST['name']; $_SESSION['cslogin'] = $_POST['cslogin']; $_SESSION['domain'] = $_POST['domain']; $_SESSION['project'] = $_POST['project']; $_SESSION['ODM'] = $_POST['ODM']; $_SESSION['hwphase'] = $_POST['hwphase']; $_SESSION['ppmid'] = $_POST['ppmid']; $_SESSION['survey'] = $_POST['survey']; $_SESSION['month'] = $_POST['month']; Then a page that decides whether to go to Q2 or Q3 that does this (even though there is no mention of Q2) $_SESSION['name'] = $_POST['name']; $_SESSION['cslogin'] = $_POST['cslogin']; $_SESSION['domain'] = $_POST['domain']; $_SESSION['project'] = $_POST['project']; $_SESSION['ODM'] = $_POST['ODM']; $_SESSION['hwphase'] = $_POST['hwphase']; $_SESSION['ppmid'] = $_POST['ppmid']; $_SESSION['survey'] = $_POST['survey']; $_SESSION['month'] = $_POST['month']; $_SESSION['Q1'] = $_POST['Q1']; $_SESSION['comment1'] = $_POST['comment1']; then the Q2 page <title>Question 2</title> </head> <body> <?php session_start(); $name = $_SESSION['name']; $cslogin = $_SESSION['cslogin']; $domain = $_SESSION['domain']; $project = $_SESSION['project']; $ODM = $_SESSION['ODM']; $hwphase = $_SESSION['hwphase']; $ppmid = $_SESSION['ppmid']; $survey = $_SESSION['survey']; $month = $_SESSION['month']; So my question was "When going to the second above, how are the POST vars re-sent?" You wouldn't need to - just re-use the session vars. Don't reset them to the (empty) post vars.
-
The id you want to update would come from $_POST['voteall'] if(isset($_POST['voteall'])) { $id = intval($_POST['voteall']); // ensure it's an integer $vote_lg = "update membertest set vote=vote+1 where id = $id"; $run_lg = mysqli_query($con, $vote_lg) or die(mysqli_error($con)); }
-
It can be both. <?php echo '<pre>',print_r($_REQUEST, true),'</pre>'; ?> <form action='?id=321' method='post'> Name <input type="text" name="name" value="Fred" size="10"> <input type="submit" name="btnSubmit" value="Submit"> </form> which give this when the form is submitted Array ( [id] => 321 // from URL [name] => Fred // from posted form field [btnSubmit] => Submit // from posted form field ) However, in this instance, I would put the id in a hidden form field so everything is POSTed rather than have a mixture
-
How are you re-sending the POST data to that intermediate page? If you aren't then all the session vars will be overwritten and set to empty.
-
Either Echo to the page and view the source Echo it to the page using htmlentities() echo htmlentities($xml_string); then you can copy/paste it.
-
while($employees=mysql_fetch_assoc($records)) { $data .= "<td>".$Employee['ID']."</td>"; Those should match.
-
You have your clauses in the wrong order, Should be UPDATE .... SET.... WHERE ....
-
It isn't too difficult. I defined a class to highlight the cell with a 4 pixel border td.now { border: 4px solid #883A66; width: 19px; height: 11px; padding: 0; } then applied that class to the cell with selected date.
-
There is an example of that in the code I posted
-
mysqli_error function require the connection as a parameter mysqli_error($con)