sasa
-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Posts posted by sasa
-
-
i don't see any error in this code
can we see all -
can you post your modifed code
-
change your form metod to GET and send keyword via url
?page=$i&keyword=$keyword
also change $_POST['keyword'] to $_GET['keyword']
btw what is $_POST['kelime'] , kelime ?? -
lines[code]if($page > 1){
$prev = ($page - 1);
echo "<a href= "" . $_SERVER['PHP_SELF'] . "?page=$prev"><Previous[/url];
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
}else {
echo "<a href= "". $_SERVER['PHP_SELF'] . "?page=$next">Next>>[/url];
}
}[/code]change to [code]if($page > 1){
$prev = ($page - 1);
echo "<a href= \"" . $_SERVER['PHP_SELF'] . "?page=$prev><Previous </a>";}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
}else {
echo "<a href= \"".$_SERVER['PHP_SELF']."?page=$i\">| $i <a>";
}
if($page<$total_pages){
$next = $page + 1;
echo "<a href= \"". $_SERVER['PHP_SELF'] . "?page=$next\">| Next> <a>;
}
}[/code] -
in[code]$this->connected == TRUE or die;[/code]script die becouse the variable $connected is not set up
-
try[code]<?php
$a=array('sasa','qwe','poi');
print_r($a);
$remowe = 'qwe';
echo "\n<hr /> Remove element $remowe\n\n";
unset($a[array_search($remowe,$a)]);
print_r($a);
?>[/code] -
change line [code]while (!$onename = mysql_fetch_array($itemnames)) {[/code]to
[code]while ($onename = mysql_fetch_array($itemnames)) {[/code]remove [color=red]![/color] -
is it variable $Layer2Scroll set up
try change [code]<?php echo "'".$Layer2Scroll."'" ?>[/code]to[code]<?php $Layer2Scroll='initial'; echo "'".$Layer2Scroll."'" ?>[/code]if it works, check twice thet yuor variable have good value -
look page source in your browser
is it look OK? -
try[code]
$pfw_message = "Visitor's IP: $pfw_ip\n"
."$sflteam, $Last_Name_drop, $First_Name_drop, $pos_drop, $team_drop, $Last_Name_retain, $First_Name_retain, $pos_retain, $team_retain";
[/code] -
try[code]echo $count1 = mysql_result($count,0,0);[/code]
-
[code]
$sql="SELECT * , SUM(hits) as total_hits, navn , url FROM toplinks, links WHERE (links_id = id) AND (date BETWEEN '$date2' AND '$date1') AND (toplinks.bolka_id < '30') GROUP BY links_id ORDER BY total_hits DESC LIMIT 10";
[/code}[/code] -
at last i setup sam data for testing. it must works
the output is just table with some data but i believe thet you can adapt it[code]
<?php
mysql_connect("localhost", "", "");
mysql_select_db("test");
// conect to database
$date1 = date('Y-m-d');
$date2 = date('Y-m-d', time()-604800);
$sql="SELECT t.links_id , SUM(t.hits) as total_hits, l.navn , l.url FROM toplinks t, links l WHERE (t.links_id = l.id) AND (t.date BETWEEN '$date2' AND '$date1') GROUP BY t.links_id ORDER BY total_hits DESC LIMIT 10";
$result = mysql_query($sql);
$nummar = 0;
echo '<table border="3"><tr><td>Numar</td><td>Links ID</td><td>Total hits</td><td>Navn</td><td>URL</td></tr>',"\n";
while ($row = mysql_fetch_assoc($result)) {
echo '<tr>';
echo '<td>',++$nummar,'</td><td>',$row['links_id'],'</td><td>',$row['total_hits'],'</td><td>',$row['navn'],'</td><td>',$row['url'],'</td></tr>';
echo "</tr>\n";
}
echo '</table>';
?>
[/code] -
add ; in line echo "</pre><hr />\n"
-
try[code]
$product_query = "SELECT * FROM `robin_basket` WHERE session_id = '".session_id()."'";
$product_result = mysql_query($product_query);
echo '<form action ="some.php" metod="POST">';
while($product_info = mysql_fetch_assoc($product_result)) {
echo "<input type='hidden' name='item_name_$i' value='{$product_info['name']}' />
<input type='hidden' name='amount_$i' value='{$product_info['price']}' />";
$i++;
}
echo '<input type="submit"></form>';
[/code] -
you dont query your database
try to make test.php[code]
<?php
// conect to database
$date1 = date('Y-m-d');
$date2 = date('Y-m-d', time()-604800);
$sql="SELECT links_id , SUM(hits) as total_hits, navn , url FROM toplinks, links WHERE (links_id = id) AND (date BETWEEN '$date1' AND '$date2') GROUP BY link_id ORDER BY total_hits DESC LIMIT 10";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
echo '<pre>';
print_r($row);
echo "</pre><hr />\n"
}
?>
[/code]and run it -
sorry i dont set GROUP BY part
it must be[code]
$sql="SELECT t.links_id , SUM(t.hits) as total_hits, l.navn , l.url FROM toplinks t, links l WHERE (t.links_id = l.id) AND (t.date BETWEEN '$date1' AND '$date2') GROUP BY t.link_id ORDER BY total_hits DESC LIMIT 10";[/code]
t is short name from table toplinks
t.links_id is field from table toplink named link_id etc.
total_hits is name for sum of value of t.hits with same links_id -
be careful to set up your array in this order. 1st set category then subject and at last response
-
$date1 = date('Y-m-d');
$date2 = date('Y-m-d', time()-604800);
$sql="SELECT t.links_id , SUM(t.hits) as total_hits, l.navn , l.url FROM toplinks t, links l WHERE (t.links_id = l.id) AND t.date BETWEEN '$date1' AND '$date2' ORDER BY total_hits DESC LIMIT 10"; -
try[code]<?php
$sum="5 + 20 / 5 - 4";
eval("\$sum = $sum;");
echo $sum;
?>[/code] -
be cereful $SQL is not same as $sql
-
pagination[code]
$query = "SELECT id FROM images";
$result = mysql_query($query) or die(mysql_error());
while ($row = mysql_fetch_array($result)) $link[] = $row['id'];
$curent = array_search($id, $link);
$prev = $curent - 1;
$next = $curent + 1;
if (array_key_exists($prev)) echo "<a href=\"?id=$link[$prev]\"> PREV </a>";
if (array_key_exists($next)) echo "<a href=\"?id=$link[$next]\"> NEXT </a>";
[/code] -
[quote author=digitalgod link=topic=105519.msg426200#msg426200 date=1157144406]
gives me the same result as what I did before... unless I'm doing something wrong
[code=php:0]
$num_rows = min($max_num_rows,mysql_num_rows($list_result));
echo "<table class='guestlist'>\n";
for ($i = 0 ; $i < $max_num_columns; $i++)
echo "<tr><td width=197><div align='center'><strong>name/nom + #</strong></div></td><td height=17 width=21><img width=17 height=17 src='images/boy.jpg'></td><td height=17 width=21><img width=15 height=17 src='images/girl.jpg'></td></tr>\n";
echo "</tr>\n";
for ($r = 0; $r < $max_num_rows; $r++){
echo "<tr>\n";
for ($c = 0; $c < $max_num_columns; $c++){
$x = $c * $num_rows + $r;
if ($x < $num_records) {
$y = mysql_result($list_result, $x, 'name');
$z= "+" . mysql_result($list_result, $x, 'number');
/*$promo = mysql_result($list_result, $x, 'promo_code');
if ($promo != "") {
$promo = "(".$promo.")";
}*/
} else {
$y = ' ';
$z = ' ';
//$promo = ' ';
}
echo "<td>$y $z </td>";
echo "<td> </td>";
echo "<td> </td>";
}
echo "</tr>\n";
}
echo "</table>\n";
for ($i=1;$i <= $total_pages;$i++) {
if ($i == $page) echo "Page $i "; else echo " <a href=\"?page=$i\">$i</a> ";
}
[/code]
[/quote]move <tr> tag from line 4 to line 2
look previous post -
try to change NULL to '' (empty string)
Transfering variable to other pages
in PHP Coding Help
Posted
//mysql db connections
$kelime= $_GET['kelime'];
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
$max_results = 2;
$from = (($page * $max_results) - $max_results);
$query="SELECT * FROM linkler WHERE kelimeler LIKE '%".$kelime."%' LIMIT $from, $max_results";
$result=mysql_query($query);
?>
<form method="get" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<table border="0" cellspacing="0" cellpadding="0">
<tr valign="middle">
<td align="left"> SEARCH <br>
<input name="kelime" type="text" class="input"> </td>
<td align="center" valign="bottom"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>
<?php
if ($_GET['kelime']){
while($record=mysql_fetch_assoc($result)){
echo "<br>";
echo $record['name'];
echo "<br>";
echo $record['url'];
echo "<br>";
echo $record['kelimeler'];
echo '<hr />';
}
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM linkler WHERE kelimeler LIKE '%".$kelime."%'"),0);
$total_pages = ceil($total_results / $max_results);
if($page > 1){
$prev = ($page - 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$prev&kelime=$kelime\">prev </a>";
}
for($i = 1; $i <= $total_pages; $i++){
if(($page) == $i){
echo "$i ";
} else {
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$i&kelime=$kelime\">| $i</a> ";
}
}
if($page < $total_pages){
$next = ($page + 1);
echo "<a href=\"".$_SERVER['PHP_SELF']."?page=$next&kelime=$kelime\">| next</a>";
}
}
?>[/code]