PHP - Split In To Several Echos
I'm pulling 10 records here. How do I split the results in to several echos?
$query = "SELECT statez, COUNT(statez)FROM mylist GROUP BY statez"; $results = mysql_query($query); $returnS=""; while($line = mysql_fetch_array($results)) { $returnS.= $line['COUNT(statez)'].",,".$line['statez'].",,,"; } echo $returnS; mysql_close($link); ?> I need the code to look like this by showing the (COUNT) number for each state. $results = mysql_query($query); while($line = mysql_fetch_array($results)) { echo $line["number_in_state1"].",,"; echo $line["number_in_state2"].",,"; echo $line["number_in_statee3"].",,"; echo $line["number_in_state4"].",,"; echo $line["number_in_state5"].",,"; echo $line["number_in_state6"].",,"; //etc.... } Similar Tutorialsok my code is below but i want to count how many $sname or ['member_name'] there is as if there is 4 or more i want it to add a marquee to it have that sorted but im having trouble getting it to count can you help me? $query = "SELECT * FROM `ibf_members` WHERE member_group_id = '4' or member_group_id = '6' or member_group_id = '17' or member_group_id = '18' or mgroup_others = '4' or mgroup_others = '6' or mgroup_others = '17' or mgroup_others = '18' "; $result99 = mysql_db_query("pbf99_backup", $query); $staff1 = mysql_num_rows($result99); if ($result99) { while ($r = mysql_fetch_array($result99)) { // Begin while $sid = $r["member_id"]; $smgid = $r["member_group_id"]; $query2 = "SELECT * FROM `ibf_sessions` WHERE member_id = '$sid'"; $result2 = mysql_db_query("pbf99_backup", $query2); if ($result2) { while ($r2 = mysql_fetch_array($result2)) { // Begin while $sname = $r2["member_name"]; $query3 = "SELECT * FROM `ibf_groups` where g_id = '$smgid'"; $result3 = mysql_db_query("pbf99_backup", $query3); if ($result3) { while ($r3 = mysql_fetch_array($result3)) { // Begin while $ssuffix = $r3["suffix"]; $sprefix = $r3["prefix"]; echo "<a href='$host$sid' target='_parent'>$sprefix$sname$ssuffix$stafff</a><br><br>"; }}}}}} ?> I'm trying to make it so that if the $row data is more than just "" (empty) then echo if not then run the scan on the next number. It just keeps repeating the values all the way through? Help? Thanks. function scan($random) { if ($random == 1) { $query = "SELECT * FROM users WHERE clicks > 20 AND status='1' ORDER BY RAND() LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); if (isset($row['id'])) { echo '<html><body style="margin: 0px;"><a href="http://www.ryansocratous.com/banner/DELETE/click.php?u=' . $row['activation'] . '"><img src="http://www.ryansocratous.com/banner/DELETE/image.php?id=' . $row['id'] . '"></img></a></body></html>'; } else { scan(2); } } if ($random == 2) { $query = "SELECT * FROM users WHERE clicks > 10 AND status='1' ORDER BY RAND() LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); if (isset($row['id'])) { echo '<html><body style="margin: 0px;"><a href="http://www.ryansocratous.com/banner/DELETE/click.php?u=' . $row['activation'] . '"><img src="http://www.ryansocratous.com/banner/DELETE/image.php?id=' . $row['id'] . '"></img></a></body></html>'; } else { scan(3); } } if ($random == 3 OR 4 OR 5) { $query = "SELECT * FROM users WHERE clicks > 0 AND status='1' ORDER BY RAND() LIMIT 1"; $result = mysql_query($query); $row = mysql_fetch_assoc($result); echo '<html><body style="margin: 0px;"><a href="http://www.ryansocratous.com/banner/DELETE/click.php?u=' . $row['activation'] . '"><img src="http://www.ryansocratous.com/banner/DELETE/image.php?id=' . $row['id'] . '"></img></a></body></html>'; } } $random = rand(1, 5); scan($random); I have a problem with formating the appearance of a die statement. As you will see from the css below, p.form and p.passed both have the same text-align, and marginal values, however they display very differently. P.passed is used in an echo, and P.form is used in a die. I want to display both my echo and die statements in the same place. Ive tried the obvious and played around with the margins on P.form but it doesnt seem to make any difference. I can only presume that my die statement is ignoring the class im assigning it? P.form { color:#FF03; margin-left:100px; text-align:left; clear:both; } P.passed { color:#333; margin-left:100px; text-align:left; clear:both; } Code: [Select] <?php // snippet if($Name == '') { die ("<P class=\"form\">You did not complete the name field, please try again</p>"); } elseif ($Phone == '' or (preg_match("/^([1]-)?[0-9]{3}-[0-9]{3}-[0-9]{4}$/i", $Phone))) { die('<P class="form"> You completed the telephone field incorrectly, please try again</p>'); } elseif ($Email == '' or (!filter_var($Email, FILTER_VALIDATE_EMAIL))) { die('<P class="form"> You completed the Email field incorrectly, please try again</p>'); } elseif ($Postcode == '' or (!checkPostcode($Postcode))) { die('<P class="form"> You did not complete the Postcode field correctly, please try again</p>'); } elseif ($Website == '' or (!preg_match("~^[a-z0-9.-]+\.(com|org|net|edu|co.uk)~i", $Website))) { die('<P class="form">You completed the website field incorrectly, please try again</p>'); } else { echo("<P class=\"passed\">Thankyou for submiting your details, you will be added to our directory shortly</p>"); }} Ive formatted if and else slightly differently but the output is still the same. Should die statements and echo's display differently? How come my$_SERVER['PHP_SELF'] echos the filename.php I have a rewrite rule and i need it to echo http://site.com/file/321 instead of filename.php?id=321 Help! Godaddy wont tell me why its doing that Hey guys it's been a long time, but I am back with php! Anyway here's my dilemma: test.php <?php <?php $name = array('Chris', 'Bob', 'Jack'); $names = print_r($name); ?> Simple enough right? Well although I am not printing/echoing these results to screen it does it automatically. Meaning when I point my browser to test.php it outputs this: Code: [Select] Array ( [0] => Chris [1] => Bob [2] => Jack ) Rather than only assigning the value to the $names variable, which is what I would expect it to do. Is this normal behaviour or is there something I can change on php.ini? Thank you! Hi, all... have a basic question here as a newbie that I am... Many times, in some scripts I see (I think, if not mistaken), places where within a echo sentence I see variables echoed like this with no quotes: echo "First Name: $firstName and Last Name: $lastName"; as opposed to like one would expect: echo "First Name: " . $firstName . " and Last Name: " . $lastName"; Sometimes I see that also when variables are used in select/update statements I think.. like this: $query = mysql_query("SELECT FROM table WHERE column = $columnname"); Instead of like this within quotes: $query = mysql_query("SELECT FROM table WHERE column = '$columnname'"); Is it because some of these values may be numbers (numeric) as opposed to "strings"?? Not sure if I make sense... appreciate teh feedback, Thanks! i have a set of array's with a similer layout as t127201103111200 what i need to do is split it like this t:1:27:2011:03:11:1200 (where the : is where i want the split but not add the : ). so i end up with this. $a = t $b = 1 $c = 27 $d = 2011 $e = 03 $f = 11 $g = 1200 what i think i need to do is Code: [Select] split(char1($a), char2($b), char3,4($c)...........................) but have no idea where to start. Thanks for any help i have same problem like you, if i open a small file(3 to 5mb), open normal. But, when i try open a dbf file 13mb or more, cause php.exe error; i set Mem in php.ini to 256mb(before 8mb), but doens't work. Someone have some solution, because i try find some way to clipper program input data on MySQL and dont have sucess too... hi everyone, i have a string as this one: 45,3455,66,8900,2,49,88,8,909 I need to print it with a new line every 4 numbers, as this one: 45,3455,66,8900, 2,49,88,8, 909 How can i do this? many thanks How can I split this data and then remove it? I need to split data by ; then split each one of those. $data = "page=1&data=1:21;2:34;5:57&a=yes"; So I will get: $category[0] = 1; $sub_category[0] = 21; $category[1] = 2; $sub_category[1] = 34; $category[2] = 5; $sub_category[2] = 57; I need to split a string, but in a very unusual way. $string1 = "HelloWorld" $string2 = "AlphaBravo" $string3 = "BreakMeUp" I need the following split at each upppercase letter for this output Hello World Alpha Bravo Break Me Up I've been trying to figure out how to split up strings such as the following: A54a1, 23b, FX49s1, R231z, 77 I would like to split them up and add them to individual arrays that are as follows: index[0] -> alphabetical characters, if any, prior to the first number, if any index[1] -> numerical characters, as a number, up until the following alphabetical character index[2] -> alphabetical character(s), if any index[3] -> numerical characters following the second alphabetical character set, if any So, for example, the above strings would be separated like this: A54a1 == ('A', 54, 'a', 1) 23b == (, 23, 'b',,) FX49s1 == ('FX', 49, 's', 1) R231z == ('R', 231, 'z',,) 77 == (,77,,) I've looked into things like strpos(), but I can't figure how to determine whether a character is alphabetic or numeric. And yes, I am familiar with the function is_numeric(). Just don't know how to throw it all together to accomplish what I need. What's the best string function to use if i want to split a string up affter a specific character? In this case i have a var with "uploads/thisImage.jpg" i want to split this so i can create a new var value of "thisImage.jpg" How do i specify that i want the fgetcsv() to use a ; to separate instead of a , p.s.(i have no control over the .csv file so i cant change it from ; to ,) Hi all, hopefully just a quickie. split is deprecated in 5.3, but i have the following to get working.. Code: [Select] $dest = split(self::__MAIL_DELIMITOR__, $this->_mails); delimitor is as follows: Code: [Select] const __MAIL_DELIMITOR__ = ',';and _mails is just a list of email addresses. Can anyone suggest a workaround? Thanks Hello to all!
I have a question. I really like that kind of button http://getbootstrap....dropdowns-split
I tried it without JS and it doen't work...
Is there a way, for user without JS to make it works?
Thanks a lot!
Pascal
Hi I am trying to split a form as shown in this simple code. I tried what I thought should work but obviously it is not working.
This submits the first part of the form but does not go to the second part of the form. So First name, Last names and Age are submitted but email and cell are not and it throws a undefined index warning for those.
Can someone please take a look at this and suggest if what I am trying to do can be accomplished using PHP.
Thanks
<?php if(isset($_POST['submit']) && $_POST['submit'] == 'Submit') { echo"<br> First Name = ".$_POST['fname']."<br>" ; echo"Last Name = ".$_POST['lname']."<br>" ; echo"Age = ".$_POST['age']."<br>" ; echo"Email = ".$_POST['email']."<br>" ; echo"Cell = ".$_POST['cell']."<br>" ; } ?> <html> <head> <title> WOW </title></head> <body> <table> <form id="form1" action = "splitform.php" method="post"> <th> TEST </th> <tr><td>First Name : </td> <td><Input type='text' name = 'fname'></td></tr> <tr><td>Last Name : </td> <td><Input type='text' name = 'lname'></td></tr> <tr><td>AGE : </td> <td><Input type='text' name = 'age'></td></tr> </form> <form id ="form1" action = "splitform.php" method="post"> <tr><td>Email : </td> <td><Input type='text' name = 'email'></td></tr> <tr><td>Cell: </td> <td><Input type='text' name = 'cell'></td></tr> </form> <tr><td><Input type="submit" name = "submit" value = "Submit" form = "form1"></tr></td> </table> </body> </html> Is it possible to split a variable into 2 variables? /// I have this sentence $item = "Below Telegraph Hill, Smallwork Canvas Edition"; /// And I want to be able to do this $item = "Below Telegraph Hill" ; $medium = "Smallwork Canvas Edition"; Is it possible to find the comma in a string, and remove the comma & everything before or after it? Any recommendations would be appreciated. hello guys
i wand to split the 24h of a day to parts and select the time that i wand to start the 24h circle to count!
lets say
i give 2 int variables
$day_starts_to_count_from=00;
$split_day_to_parts=4;
so!
$hours_per_part = 24/$split_day_to_parts;
this gives me $hours_per_part = 6 (i split the 24h every 6hr)
how to know the part of my current hour?
lets say the system time is 15:35
how to find that im at the 3d part 12:00-18:00 if the 24h circle starts to count from 00:00
thanks in advance
Hi all, I am working on the PHP to fetch the data from the database. I would like to fetch the filename only following by: email1.png email2.png email3.png my_inbox.png
When I try this: $mailbox_sql = 'SELECT * FROM ' . $mailfolder . ' WHERE email_id = ? AND message_id = ?'; $mailbox = $link->prepare($mailbox_sql); $mailbox->execute([$id,$message_id]); // set the resulting array to associative $row = $mailbox->fetch(PDO::FETCH_ASSOC); if (is_array($row)) { $attached = $row['attached_files']; $attached_files_name = explode('attid: ', $attached); }
I am getting this: 0 filename: email1.png 1 filename: email2.png 2 filename: email3.png 3 filename: my_inbox.png
Here is what I have stored in the database: attid: 0 filename: email1.png attid: 1 filename: email2.png attid: 2 filename: email3.png attid: 3 filename: my_inbox.png
Here is what I want to achieve: email1.png email2.png email3.png my_inbox.png
Can you please show me example how I could get the filename when I am fetching the data from the database? Thanks in advance. Edited January 18, 2020 by mark107 |