sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
try <?php require("conf.php"); //max displayed per page $per_page = 5; //get start variable if (isset($_GET['start']))$start = $_GET['start']; else $start = 0; if(isset($_POST['udf'])) { $udfin = $_POST['udf']; } elseif(isset($_GET['udf'])) { $udfin = $_GET['udf']; } else { $udfin = 1; } //count records $record_count = mysql_num_rows(mysql_query("SELECT * FROM cy_equ WHERE udf = $udfin")); //count max pages $max_pages = $record_count / $per_page; //may come out as decimal if (!$start) $start = 0; //display data $get = mysql_query("SELECT * FROM cy_equ WHERE udf = $udfin LIMIT $start, $per_page"); while ($row = mysql_fetch_assoc($get)) { // get data $id = $row['id']; $ext = $row['ext']; $equ = $row['equ']; $udf = $row['udf']; $udf1 = $row['udf1']; $udf2 = $row['udf2']; echo " ID (".$id.") EXT (".$ext.") EQU (".$equ.") UDF (".$udf.") UDF1 (".$udf1.") UDF2 (".$udf2.")<br />"; } //setup prev and next variables $prev = $start - $per_page; $next = $start + $per_page; //show next button if (!($start>=$record_count-$per_page)) echo " <a href='qqq.php?udf=$udfin&start=$next'>Next</a>"; //show prev button if (!($start<=0)) echo "<a href='qqq.php?udf=$udfin&start=$prev'>Prev</a> "; //show page numbers //set variable for first page $i=1; for ($x=0;$x<$record_count;$x=$x+$per_page) { if ($start!=$x) echo " <a href='qqq.php?udf=$udfin&start=$x'>$i</a> "; else echo " <a href='qqq.php?udf=$udfin&start=$x'><b>$i</b></a> "; $i++; } ?> <h3> UDF Query </h3> <form name="form1" method="post" action="http://localhost/qqq.php"> <p> Input UDF: <input type="number" name="udf" value= "<?php echo $udfin; ?>" size="1" maxlength="4"/></p><br> <p> Q = <font color="red"><?php echo $id; ?> </font> </p> <p> EXT = <font color="red"><?php echo $ext; ?> </font> </p> <p> EQU = <font color="red"><?php echo $equ; ?> </font></p> <p> UDF = <font color="red"><?php echo $udf; ?> </font></p> <p> UDF2 = <font color="red"><?php echo $udf2; ?> </font></p> <p> UDF3 = <font color="red"><?php echo $udf3; ?> </font></p> <p><input type="submit" name="submit" value="GET DATA"/></p> </form>
-
try <?php $temp = array(array('north america', 'us', 'california'), array('north america', 'us', 'hawaii'), array('north america', 'canada', 'vancouver'), array('asia', 'singapore', 'orchard')); $out = array(); foreach ($temp as $t) $out[$t[0]][$t[1]][] = $t[2]; print_r($out); ?>
-
Querying info from one table based on info in another
sasa replied to weemee500's topic in PHP Coding Help
changr to $subsQuery = mysql_query("SELECT U.username FROM users AS U INNER JOIN subscription AS Sub ON Sub.follow_id=U.id WHERE Sub.user_id=".$ID); -
you must pass odf parameter via url
-
change line <option value="<?php $row['id']; ?>"><?php echo $row['day']; ?></option> to <option value="<?php echo $row['id']; ?>"><?php echo $row['day']; ?></option>
-
change to $getdata = mysql_query("SELECT * FROM sbt WHERE country LIKE '%$country%' AND state LIKE '%$state%' ORDER BY `id` DESC LIMIT $cur, $max") or die(mysql_error()); // select the results //$data = mysql_fetch_array($getdata); // get the data while($user = mysql_fetch_array($getdata)) { echo $user['company'] . '<br />'; }
-
use loop
-
try <?php if (isset($_POST['username']) { echo "fsaf"; } else { echo "<form name=\"login\" method=\"post\" action=\"index.php\">"; ... you must escape " inside "
-
variable $resources does NOT exist outside function!!
-
try select count(*) as count,referral, AVG(conversion) as conversions from visitors group by referral order by count
-
try <?php $values = array(); for($h=1; $h<$rowcount; $h++) { $val = array(); ##### GET VALUES ##### for($e=1; $e<$fieldcount; $e++) { $val[] = $_POST[$e][$h]; } $values[] = "('". implode("', '", $val) . "')"; } $values = implode(",\n",$values); ?>
-
[SOLVED] Countdown to first tuesday of every month.
sasa replied to TRemmie's topic in PHP Coding Help
try <?php function days_to_next_tu(){ $day = date('t')-date('j'); $f = mktime(0,0,0,date('n')+1,1,date('y')); $d = date('w', $f); $t = $d > 2 ? 9-$d: 2-$d; return $day+$t+1; } echo days_to_next_tu(); ?> -
use ceil($l/3)*3
-
move line mail($to, $subject, $message, $headers); outside foreach loop
-
move part that send mail into 1st foreach loop
-
try <?php $users_score = array( 'user1' => 123, 'user2' => 123, 'user3' => 123, 'user4' => 124, 'user5' => 124, 'user6' => 125, 'user7' => 125, 'user8' => 125, 'user9' => 125, 'user10' => 125, 'user11' => 125, 'user12' => 126, 'user13' => 127, 'user14' => 128, 'user15' => 129 ); $pey_out = range(10, 150, 10); rsort($pey_out); //print_r($pey_out); $x = array_count_values($users_score); krsort($x, 0); $new_pey= array(); $y = $pey_out; foreach ($x as $k => $v){ $s = 0; for ($i = 0; $i < $v; $i++) $s +=array_shift($y); $new_pey[$k] = $s / $v; } foreach ($users_score as $us => $sc) echo $us, ' -> ', $new_pey[$sc], "<br />\n"; ?>
-
try SELECT * FROM product WHERE Type = '$type' GROUP BY LEFT(Stock, 5) ORDER BY Stock DESC $limit
-
http://www.phpfreaks.com/forums/index.php/topic,95426.0.html
-
change your function to public function viewContainer() { $total = count($this->container); print_r($this->container); print($total); }
-
try to close open textarea tag echo"<textarea name='englandsong' cols='80' rows='30' value='{$stuff['Comp1england']}'></textarea>";
-
echoing only 1 row from database when values are similar.
sasa replied to seany123's topic in PHP Coding Help
are you try this? if you can use phpmyadmin with your database try to use this SQL SELECT i.*, b.*, COUNT(i.id) AS amount FROM items i LEFT JOIN blueprint_items b ON i.item_id=b.id WHERE i.player_id=1 GROUP BY i.item_id -
echoing only 1 row from database when values are similar.
sasa replied to seany123's topic in PHP Coding Help
try to do all work with one query somehing like SELECT i.*, b.*, COUNT(i.id) FROM items i LEFT JOIN blueprint_items b ON i.iteem_id=b.id WHERE player_id=? GROUP BY i.item_id not tested -
try <?php function my_move($start, $end, $speed){ if (($start[0] - $end[0]) * ($start[0] - $end[0]) + ($start[1] - $end[1]) * ($start[1] - $end[1]) <= $speed * $speed) return $end; $angle = atan2($end[1] - $start[1], $end[0] - $start[0]); return array($start[0] + cos($angle) * $speed, $start[1] + sin($angle) * $speed); } $currentXY = array(100, -100); $finalXY = array(-200, 300); $speed = 1; while ($currentXY != $finalXY and $i++<1000){ print_r($currentXY); $currentXY = my_move($currentXY, $finalXY, $speed); } ?>
-
change <select name 'keywords'> to <select name='keywords'>