sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
you mean $num=mysql_num_rows($result);
-
OK do it in your way but don't ask for help
-
you must escape 1st ! and remove 2nd one <?php $string = "<!--HELLO WORLD-->"; $tags = "/<\!--(.*?)-->/"; preg_match($tags, $string, $matches); print_r($matches[1]); ?>
-
output of your last post is not from your form code are you shure that edit right file i insert some coments in your code i'm shure you can understund it i think that is beter way to choice separeted wit questin while( $info = mysql_fetch_array( $sqll )) //)) { echo "{$info['Que_ID']} <br />\n"; // i hope that is PK from your table echo "<input type='hidden' name=\"Que_ID\" value=\"{$info['Que_ID']}\" /> "; // name from this field must be array //it's mean that name=\"Que_ID[]\" add [] to name echo "{$info['Que_Question']} <br />\n"; echo "<input type=\"checkbox\" name=\"choice[$counter]\" value=\"{$info['Que_Choice1']}\" /> "; //transform name in 2 dimensinal array //1st dimension is for which question is answer, and 2nd just for enable multliply answers // name=\"choice[{$info['Que_ID']}][]\" // if $info['Que_ID'] = 1 in $_POST['choice'][1] is array of all chcked ansvers for question with id=1 // $_POST['choice'][12] is array of all chcked ansvers for question with id=12 etc. //warning! if noting checked for questinh x, $_POST['choice'][x] is not set // if notin checked at all $_POST['choice'] is not set echo "{$info['Que_Choice1']} <br />\n"; ...
-
try <?php $test = '<TD valign="top"><B>name</B></TD> <TD>Administrators</TD> </TR> <TR> <TD valign="top"><B>inUse</B></TD> <TD>true</TD> </TR> <TR> <TD valign="top"><B>allow</B></TD> <TD valign="top"><B>name</B></TD> <TD>Users</TD> </TR> <TR> <TD valign="top"><B>inUse</B></TD> <TD>true</TD> </TR> <TR> <TD valign="top"><B>allow</B></TD> <TD valign="top"><B>name</B></TD> <TD>Developers</TD> </TR> <TR> <TD valign="top"><B>inUse</B></TD> <TD>true</TD> </TR> <TR> <TD valign="top"><B>allow</B></TD>'; preg_match_all('/<TD valign="top"><B>name<\/B><\/TD>.*?<TD>([^<]+)<\/TD>/is', $test, $out); print_r($out[1]); ?>
-
look http://www.phpfreaks.com/forums/index.php?topic=95426.msg381816#msg381816
-
try $types = array(); while ($row = mysql_fetch_array($query_name,MYSQL_NUM)) { $types[] = $row[0]; } print_r ($types);[/codeg
-
try[codeg<?php function my_link($a = 'i_need_link'){ static $i = 0, $array = array(); if($a == 'i_need_link') return $array; $i++; $array[$i]= $a[0]; return "<$i>"; } $test = 'blah blah www.a.com bla bla blaa b.com aaaa sss c.org bla'; $test1 = preg_replace_callback('/\S+\.\S+/', 'my_link', $test); $links = my_link(); echo $test1,"\n<hr />\n"; print_r($links); ?>
-
preg_match_all('|<img src="/images/product/icon/(.+?).jpg|', $str, $matches); foreach ($matches[1] as $select) echo $select, '<br>';
-
change your query to $query = "SELECT * FROM restaurants WHERE state=" .mysql_real_escape_string($theChoice);
-
post relevant code
-
try preg_match('/(\S+\.\S+)/', $text, $out); print_r($out);
-
i just put brecket in wrong place line 6th must be echo "Question id: ".$question. implode(', ',$choice)."<br />";
-
How to apply a condition to the display of an array
sasa replied to facarroll's topic in PHP Coding Help
try <?php $query1 = mysql_query("SELECT DISTINCT quizTitle, userId, SUM(passState) as pass, MAX(userScore) as u_sore, totalScore, DATE_FORMAT(userDate,'%b %e, %Y') AS userDate FROM quiz WHERE managerId = '$managerId' AND userId = '$userId' GROUP BY quizTitle ORDER BY quizTitle, userDate ASC"); while ($row = mysql_fetch_array($query1)) { echo "{$row['quizTitle']} <br />\n"; echo "{$row['userDate']} <br />\n"; if ($row['pass'] > 1) {echo "<img src=' ../../wood/wood_tool_images/tick2.png' /><br />\n";} if ($row['pass'] == 0) {echo "<img src=' ../../wood/wood_tool_images/cross2.png' /><br />\n";} echo $row['u_score'].'/'.$row['totalScore']; } ?> -
change form to <?php while( $info = mysql_fetch_array( $sqll )){ echo "<input type='hidden' name=\"Que_ID[]\" value=\"{$info['Que_ID']}\" /> "; echo " $intNum, {$info['Que_Question']} <br />\n<br />\n"; for ($i =1; $i < 5; $i++) { echo "<input type=\"checkbox\" name=\"choice[{$info['Que_ID']}][]\" value=\"$i\" />{$info['Que_Choice'.$i]}"; } } ?> and your action page to <?PHP foreach ($_POST["Que_ID"] as $question) { $_POST["choice"][$question] = $choice; echo "Question id: ".$question. implode(', ',$choice")<br />";
-
try <?php class Paginator{ //... function my_p_number($total_pages, $current, $before = 2, $after = 3){ $out = array(1); $out = array_merge($out, range(min($total_pages-$before-$after,max(1, $current - $before)), max($before+$after+1,min($total_pages, $current + $after)))); $out[] = $total_pages; $out = array_unique($out); sort($out); return $out; } function paginate(){ $this->numPages = ceil($this->itemsTotal / $this->itemsPerPage); $p = Paginator::my_p_number($this->numPages, $this->currentPage); $t = 0; foreach ($p as $i){ if($i - $t > 1) $this->output .= ' ... '; if ($i == $this->currentPage){ $this->output .= "<span class=\"paginate current\" onclick=\"goPage(this)\" data-page=\"" . $i . "\">" . $i . "</span> "; }else{ $this->output .= "<span class=\"paginate\" onclick=\"goPage(this)\" data-page=\"" . $i . "\">" . $i . "</span> "; } $t=$i; } } } ?>
-
try <?php function my_ofset($text){ preg_match('/^[^\-]*-\D*/', $text, $m); return strlen($m[0]); } echo my_ofset('[HorribleSubs] Bleach - 311 [720p].mkv'); ?>
-
it take so long time to print all combinations just uncomment last but one line
-
try '%\](.*?)(\(|\[)%mis'
-
<?php $string = 'Cuckoo Alex# Rub a 15 Dub Transportation Squirters for the Tub bath toy! age10'; $semiclean = preg_replace('/[^a-z0-9 ]/i', '', $string); $clean = trim(preg_replace('/\b[a-z0-9]*[0-9][a-z0-9]* ?\b/i', '', $semiclean)); echo $final = preg_replace('/^([a-z]+)\b.*([a-z]+).\b([a-z]+)$/i', '\1 \2 \3 ', $clean); ?>
-
UPDATE in WHILE loop only adding last value and not all values
sasa replied to zdvdla's topic in PHP Coding Help
in SQL you can ORDER BY (field1 + field2) -
use two query or use UNION of two query
-
UPDATE in WHILE loop only adding last value and not all values
sasa replied to zdvdla's topic in PHP Coding Help
you need WHERE part in your update query without this query update all rows -
try <?php $test = range(1,10); $text = 'blah'; foreach($test as $n){ echo "$n - $text<br />\n"; $text = 'crazy'; } ?>