-
Posts
3,372 -
Joined
-
Last visited
-
Days Won
18
Everything posted by Muddy_Funster
-
I think you want array_replace() instead of array_diff()
-
I can't help any with the CSS, since it's not in the included code, but paste this into the appropriate part of the code I gave you to see an example of how to catch the info from the form: ... // end of test data //sample catch form output: if(!isset($_POST['submit'])){ } else{ echo"<pre>"; print_r($_POST); echo "</pre>"; } //end sample form catch foreach($results as $key=>$row){ if($row['active'] == 1){ $checkboxes = "<td> Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' checked='checked' />\n\r Suspendido<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='0' />"; } else{ $checkboxes = "<td> Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' />\n\r Suspendido<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='0' checked='checked' />"; } ...
-
Without knowing anything about the server or it's connection to the clients, or the number of clients you ware targeting it's impossible to resonable deductions to the effect that your application would have on said server. So moving on to the rest of the question, you want to look into AJAX long polling if you are planing on doing this with just PHP and javascript. However, there is a better way. There are a couple of frameworks out there, Node.js being one of the biggest, that will facilitate server push without having to constantly poll the server from every client. I recomend taking the time to aquaint yourself with Node.js before making any decissions regarding how you plan to tackle this.
- 10 replies
-
right, I have this working with the test data included - by working I meen that it renders the table on screen and provides individual buttons for each from. <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> ... <table> <tbody> <?php //Your Database Connection Code: /* include "config.php"; $id=$_GET['id']; $qry=mysql_query("select * from register where id='$id'"); $count=mysql_num_rows($qry); $results = mysql_fetch_assoc($qry); */ //offline test dataset to map out variables into table elements $results = array( array( 'id'=>'1', 'active'=>'1', 'fname'=>'Adam', 'lname'=>'Zacharia', 'mobile'=>'0125555225', 'email'=>'adam@your.net', 'city'=>'New Heaven', 'company'=>'Angel Investment Inc', 'address'=>'123 wherever lane, 905668' ), array( 'id'=>'2', 'active'=>'0', 'fname'=>'Charles', 'lname'=>'Lindberg', 'mobile'=>'0168755225', 'email'=>'Chic@your.net', 'city'=>'Old Hampshire', 'company'=>'Global Avionics LTD', 'address'=>'456 nowhere place, 998768' ) ); // end of test data foreach($results as $key=>$row){ if($row['active'] == 1){ $checkboxes = "<td> Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' checked='checked' />\n\r Suspendido<input type='radio' name='radio' id='radio' value='0' />"; } else{ $checkboxes = "<td> Activo<input type='radio' name='radio{$row['id']}' id='radio{$row['id']}' value='1' />\n\r Suspendido<input type='radio' name='radio' id='radio' value='0' checked='checked' />"; } $pageOut = <<<PAGEOUT <form method="POST" action='#'> <tr> <th width="40%">Primeiro Nome</th> <th><input type="text" name="fname" class="form-control" placeholder="Introduz Nome" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['fname']}" required></th> </tr> <tr> <th width="40%">Ultimo Nome</th> <th><input type="text" name="lname" class="form-control" placeholder="Intrudos Apelido" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['lname']}" required></th> </tr> <tr> <th width="40%">Numero</th> <th><input type="text" name="mobile" class="form-control" placeholder="Introduz Numero" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['mobile']}" required></th> </tr> <tr> <th width="40%">Email</th> <th><input type="text" name="email"class="form-control" placeholder="Introduz Email" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['email']}" required></th> </tr> <tr> <th width="40%">Cidade</th> <th><input type="text" name="city"class="form-control" placeholder="Introduz Cidade" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['city']}" required></th> </tr> <tr> <th width="40%">Empresa</th> <th><input type="text" name="company"class="form-control" placeholder="Introduz Empresa" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['company']}" required></th> </tr> <tr> <th width="40%">Morada</th> <th><input type="text" name="address"class="form-control" placeholder="Introduz Morada" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['address']}" required></th> </tr> <tr> <th>Activo/Suspendido</th> {$checkboxes} <input type="hidden" name="id" value="{$row['id']}" /> <input type="hidden" value="Submit" name="submit" /> </td> </tr> <tr> <td><header class='panel-heading'><div align='center'><button type='submit' class='btn btn-primary'>Editar</button></div></header></td><td></td> </tr> </form> PAGEOUT; echo $pageOut; } echo "</tbody> \n\r </table> \n\r " ?> see how that gets on.
-
Right...I think I get what's going on here, give me a moment...
-
meh, I echoed the wrong variable name, sorry: change echo $output; to echo $pageOut;
-
How can I get a "load more" to request more data from the server?
Muddy_Funster replied to Q695's topic in Javascript Help
Hugs are always good lol...and so is getting passed a roadblock. Glad to have helped. -
well as long as it's working, that's what counts.
-
Set variable based on another variable - CASE?
Muddy_Funster replied to simonp's topic in PHP Coding Help
you may want to have a final else to catch any prospective errors, not everything goes to $plan... (sorry couldn't resist ) -
that's just because I missed the ; at the line echo $preLoop add one in and see what happens: echo $preLoop;
-
try this: <?php $preLoop = <<<PRE_LOOP <div id="wowslider-container1"> <div class="ws_images"> <ul> PRE_LOOP; echo $preLoop $counter = 0; while ($row_louvers == mysql_fetch_assoc($louvers)){ $loopString = <<<LOOP_STRING <li><img src="uploads/{$row_louvers['foto_dosya']}" alt="1" title="{$row_louvers['foto_baslik']}" id="wows1_0-{$counter)"/></li> <div class="ws_bullets"> <div> <a href="#" title="THUMBNAIL"><span> <img src="uploads/{$row_louvers['foto_dosya']}" alt="1" width="117" height="48"/></span></a> </div> </div> LOOP_STRING; $counter++; echo $loopString; }; $postLoop = <<<POST_LOOP </ul> </div> </div> POST_LOOP; echo $postLoop; ?>
-
The error and the code that you posted don't match. The connection string for mysqli looks like this: mysqli_connect("myhost","myuser","mypassw","mybd") So the error Access denied for user ''@'localhost' to database 'shazz' meens that the "myuser" parameter is empty, not the "mypassw" as you show in your code.
-
You should have started a new thread for a different problem. The issue is that you have not created your while loop properly. I'm not sure what's supposed to be part of the loop and what isn't, but I have restructured your code and fixed your loop. look into heredoc statements in order to remove the need to keep bustring in and out of php tags. this is meant as a guideline, not a plug-in fix. I also added a counter to ensure that you maintain unique IDs for the list items. $counter = 0; while ($row_louvers == mysql_fetch_assoc($louvers)){ $loopString = <<<LOOP_STRING <div id="wowslider-container1"> <div class="ws_images"> <ul> <li><img src="uploads/{$row_louvers['foto_dosya']}" alt="1" title="{$row_louvers['foto_baslik']}" id="wows1_0-{$counter)"/></li> </ul> </div> <div class="ws_bullets"> <div> <a href="#" title="THUMBNAIL"><span> <img src="uploads/{$row_louvers['foto_dosya']}" alt="1" width="117" height="48"/></span></a> </div> </div> </div> LOOP_STRING; $counter++; echo $loopString; }
-
Why have you put brackets around LOUVERS? if($row_slider_cek['slider_name'] == ['LOUVERS']){ try changing it to if($row_slider_cek['slider_name'] == 'LOUVERS'){ also, try and make more relevent debuging messages: }else{ echo 'could not include slider file as $row_slider_cek returned '.$row_slider_cek['slider_name']; }?>
-
you are still decalring the same function multiple times, move the function decleration out of the loop above the table code. and try changing your code to something more like to following (it's been a long time since I used mysql_ so it will probably need a bit of tweeking: <script> function alpha(e) { var k; document.all ? k = e.keyCode : k = e.which; return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8 || k == 32 || (k >= 48 && k <= 57)); } </script> ... <tbody> <?php include "config.php"; $id=$_GET['id']; $qry=mysql_query("select * from register where id='$id'"); $count=mysql_num_rows($qry); $results = =mysql_fetch_assoc($qry); foreach($results as $row){ if($row['active'] == 1){ $ckeckboxes = "<td> Activo<input type='radio' name='radio' id='radio' value='1' checked='checked' />\n\r Suspendido<input type='radio' name='radio' id='radio' value='0' />"; } else{ $ckeckboxes = "<td> Activo<input type='radio' name='radio' id='radio' value='1' />\n\r Suspendido<input type='radio' name='radio' id='radio' value='0' checked='checked' />"; } $pageOut = <<<PAGEOUT <tr> <th width="40%">Primeiro Nome</th> <th><input type="text" name="fname" class="form-control" placeholder="Introduz Nome" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['fname']}" required></th> </tr> <tr> <th width="40%">Ultimo Nome</th> <th><input type="text" name="lname" class="form-control" placeholder="Intrudos Apelido" onKeyPress="alpha(event)" style="text-transform:lowercase;" value="{$row['lname']}" required></th> </tr> <tr> <th width="40%">Numero</th> <th><input type="text" name="mobile" class="form-control" placeholder="Introduz Numero" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['mobile']}" required></th> </tr> <tr> <th width="40%">Email</th> <th><input type="text" name="email"class="form-control" placeholder="Introduz Email" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['email']}" required></th> </tr> <tr> <th width="40%">Cidade</th> <th><input type="text" name="city"class="form-control" placeholder="Introduz Cidade" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['city']}" required></th> </tr> <tr> <th width="40%">Empresa</th> <th><input type="text" name="company"class="form-control" placeholder="Introduz Empresa" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['company']}" required></th> </tr> <tr> <th width="40%">Morada</th> <th><input type="text" name="address"class="form-control" placeholder="Introduz Morada" onKeyPress="return alpha(event)" style="text-transform:lowercase;" value="{$row['address']}" required></th> </tr> <tr> <th>Activo/Suspendido</th> {$checkboxes} <input type="hidden" name="id" value="{$_GET['id']}" /> <input type="hidden" value="Submit" name="submit" /> </td> </tr> PAGEOUT; echo $output; } echo "</tbody> \n\r </table> \n\r <header class='panel-heading'><div align='center'><button type='submit' class='btn btn-primary'>Editar</button></div></header></form>" ?>
-
I told you not to declare the function multiple times, declare it only once at the start of your page and then refference it mutiple times: function myFunct(){ ... } ... ...onClick = "myFunct()"... ... ...onChange = "myFunct()"... ... If you have made changes to your code please repost the new code with the current behaviour: What it doesn't do + What it does do + What it should do | and include a summary of your changes. help us to help you.
-
How can I get a "load more" to request more data from the server?
Muddy_Funster replied to Q695's topic in Javascript Help
Yeah...still not getting it, sorry. However, just so this reply isn't completly useless, here's your $.ajax broken down (and fixed a bit) $.ajax({ type: 'GET', url: 'load_more/results.php?revision='+i, //add a variable to the URL that will carry the value in your i counter through to the PHP page so it know's if this is new or additional data success: function(data){ // this param name was confusing, I have changed it to the "normal" name to make it clear that it contains the data returned from the request //load more data to "wrap" div wrap.innerHTML =+ (data); // as above, data holds the result of the request, so all the data returned from your results.php file are in this param but please see below // $('#wrap').append(data); // this is the jQuery method for adding more content after the last child in a container. It's more robust than the way you are doing it console.log('success'+i); // I'll just leave this here } }) Hope that helps some. You will of cource have to have something on your php page to handle $_GET['revision'] for the above to properly work. -
since we have taken a pedantic turn here: $_SESSION isn't a function, it's a superglobal variable array. also, you should check for if(!isset()) rather than if(isset()) as the latter can still throw a "Warning: <xxx> is undefined" in the event that the thing you are checking isn't actually set (at least in some older versions of PHP, dont know about the more recent versions because I stopped doing it...).
-
You missed the bit that's not working...Although I see you are refferencing $_GET['bidDate'] and $_GET['dueDate'] and they arn't in the URL. Are they represented by $_GET['start'] and $_GET['end'] by chance?
-
why in the name of <insert word(s) here> would you want to carry password info in plaintext through a session ??
-
substr('fname', 0, 1);
-
right, that meens that at the point it get's to the query build it's not a 2D array like it said it was, make sure your vardump is directly before your query and try it again, somethings not adding up with that. also, $parts = array_map('trim', explode('&', $stypest)); //what does trim do? // now split each part of that array by the '=' to get the key/values foreach ($parts as $part) { $keyvals = array_map('trim', explode('=', $part)); // and why do you do it again here? } /* consider changing the above to: foreach($parts as $part){ $twoDeepKeyVals[] = explode("=",$part)) } foreach($twoDeepKeyVals as $row){ $keyVals[$row[0]] = $row[1]; } print_r($keyVals);
-
From the results of your var_dump you want $keyvals[0][1] and $keyvals[1][1] as your variables SELECT * FROM bids b where b.BidStatus = '".$keyvals[0][1]."' AND b.AliasID = '".$keyvals[1][1]."' it also means that your prevois atempts shouldn't have worked at all....
-
If you need to ask then you don't need to wory about it. This is for php libraries and frameworks that arn't widely enough used to make it into the named lists in the other sections. It's a bit neiche.
-
and again....