sasa
Staff Alumni-
Posts
2,804 -
Joined
-
Last visited
-
Days Won
1
Everything posted by sasa
-
ups change line if($page <= $numofpages) { to if($page < $numofpages) { before echo NEXT link
-
SELECT cust_name, count(*) AS number FROM table_jobs WHER current_status='printed' GROUP BY cust_name
-
try <?php $dbservertype='mysql'; $servername='localhost'; // username and password to log onto db server $dbusername='root'; $dbpassword=''; // name of database $dbname='lopesarms'; connecttodb($servername,$dbname,$dbusername,$dbpassword); function connecttodb($servername,$dbname,$dbuser,$dbpassword) { global $link; $link=mysql_connect ("$servername","$dbuser","$dbpassword"); if(!$link){die("Could not connect to MySQL");} mysql_select_db("$dbname",$link) or die ("could not open db".mysql_error()); } error_reporting(E_ALL); ini_set('display_errors', '1'); $limit = 4; $query_count = "SELECT count(*) FROM guest_book"; $result_count = mysql_query($query_count); //$totalrows = mysql_num_rows($result_count); <-- change this line $totalrows = mysql_result($result_count, 0, 0); if(empty($page)){ $page = 1; } $limitvalue = $page * $limit - ($limit); $query = "SELECT * FROM guest_book LIMIT $limitvalue, $limit"; $result = mysql_query($query) or die("Error: " . mysql_error()); echo"$totalrows"; if(mysql_num_rows($result) == 0){ echo("Nothing to Display!"); } $bgcolor = "#E0E0E0"; // light gray echo("<table>"); while($row = mysql_fetch_array($result)){ if ($bgcolor == "#E0E0E0"){ $bgcolor = "#FFFFFF"; }else{ $bgcolor = "#E0E0E0"; } echo("<tr bgcolor=".$bgcolor."><td>"); echo($row["name"]); echo($row["email"]); echo("</td></tr>"); } echo("</table>"); echo"<font size=2>"; $pageprev = $page-1; if($page != 1){ echo("<a href=\"$PHP_SELF?page=$pageprev\">PREV</a> "); }else{ echo("PREV"." "); } //$numofpages = $limit / $totalrows; <-- change this line $numofpages = ceil($totalrows /$limit); for($i = 1; $i <= $numofpages; $i++){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } /* remove this part if(( $limit % $totalrows) != 0){ if($i == $page){ echo($i." "); }else{ echo("<a href=\"$PHP_SELF?page=$i\">$i</a> "); } } */ $pagenext = $page+1; //$new = ($limit * $page) - $totalrows; <-- and remove this part //echo"$new"; if($page <= $numofpages) { echo("<a href=\"$PHP_SELF?page=$pagenext\">NEXT</a>"); }else{ echo("NEXT"); } echo"</font>"; mysql_free_result($result); ?>
-
if you want to output array just ones move print_r function outside 6 loops you can change print_r($TOTAL) with foreach($TOTAL as $v) echo $v, '<br />';
-
try $request = ucwords(strip_tags(str_replace($Bad,'panda',$_POST['textfield3'])));
-
or if($a & 1) echo 'odd'; else echo 'even';
-
$pageprev = $page--; do: 1st assign value of variable $page to variable $pageprev 2nd AFTER that change value of variable $page if $page = 7 after $pageprev = $page--; you got $pageprev = 7 and $page = 6 !!! you want $pageprev = $page - 1; if $page = 7 after $pageprev = $page - 1; you got $pageprev = 6 and $page = 7
-
<form name="Remove" method="post" action="Remove.php"> <table width="100%"> <? $query = "select assignments.*, Activities.ActivityName from assignments, Activities where UserID = '" . $_SESSION['usertid'] ."' and assignments.AssignmentID = Activities.AssignmentID"; $result = $db_conn->query($query); $num_results = $result->num_rows; for ($i=0; $i <$num_resultsEnrol; $i++) { $row = $result->fetch_assoc(); $ActivityID = $row["ActivityID"]; //$query1 = "select *from Activities where ActivityID = '" . $ActivityID."'"; //$result1 = $db_conn->query($query1); //$row = $result1->fetch_assoc(); echo '<tr>'; echo '<td>'.$row["ActivityID"].': '.$row["ActivityName"].'</td>'; echo '<td align="right"><input type="submit" value="Remove" name="',$row['AssignmentID'],'></td>'; echo '</tr>'; } echo '</table></form>'; ?> [/quote]and in Remove.php[code]$key = array_search('Remove', $_POST); if($key) { $query = "DELETE FROM assignments WHERE AssignmentID=$key"; $result = $db_conn->query($query) or die($query); } [/code]
-
try while ($row = mysql_fetch_array($qry)) { if ($i == 0) { echo "<td style='width:33%'>"; } echo '<div id="brand">'; echo '<a href="'.$_HTTPS['PHP_SELF'].''.$row['page'].'.php?sku='.$row['sku'].'">'; echo $row ['brand']; echo "</a>"; echo '</div>'; $i++; if ($i == $max){ echo '</td>'; $i = 0; } }
-
look http://www.phpfreaks.com/forums/index.php/topic,155530.0.html
-
try <?php echo'<td class='.$class_bg.'> <table width="25" border="0" cellspacing="1" cellpadding="0" align="center"> <tr> <td> </td> <td align="right" valign="top" class="'.$date_class.'"><a href="#" onMouseOver="doTooltip(event, msgTips)" onmouseout="hideTip();" class="'.$date_class.'">'.$i.'</a></td> <td style="width:3px">',$_SESSION['myday'],'</td> </tr> <tr> <td colspan="3"><table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td colspan="2" style="height:8px"></td> </tr> </table></td> </tr> </table> </td>'; ?>
-
[SOLVED] How to count the # if instances an ID is in a table?
sasa replied to BadGoat's topic in PHP Coding Help
echo $r['citycount']; -
change '~\\~' to '~\\\~'
-
try <?php $remove = "And|Or|If|We|An|A|I|"; $a = 'Anderson and Bill oR Orr'; $b = preg_replace('/[^a-z0-9_](?:'.$remove.')([^a-z0-9_]|$)/i',"$1",$a); echo $b; ?>
-
change to $query=mysql_query( "INSERT INTO basket (ProductID, ProductPrice, ProductName) VALUES ('$id','$price','$name')") or die("couldnt");
-
try $hello = 123; $a ='hello'; echo $$a;
-
[SOLVED] Quick and easy way to truncate a date string?
sasa replied to Moron's topic in PHP Coding Help
what date is string '1112005'? -
change <?include("conninfo.php")?> to <?php include("conninfo.php"); ?>
-
use nl2br() function before echo text
-
... echo '<td class="release" align="release"><b><a href="browse.php?cat_id='.$category['id'].'">'.$category['name'].'</b></a></td>'; $count++; } //insert line if($count > 1) for($I = $count; $i <= 5; $i++)echo '<td> </td>'; echo '</tr></table>';
-
try echo $is_this_admin = ($admin == 'Site Administrator') ? '[<a class="altlink" href="edit.php?id='.$id.'&editedby='.$upper.'"><b>EDIT</b></a>]-[<a class="altlink" href="delete.php?id='.$id.'"><b>DELETE</b></a>]' : "";
-
let see when you finish while loop in variable $row is value false (0 as int or '' as str) in variable $username is value of last username from db if user check last checkbox $_POST[$username] isset and $item have value but $row['usernam'] is false ('') and 1st if not pass if user not check last checkbox $_POST[$username] is not set and $item have value '' $row['username'] have value '' and 2nd if pass then $query have value "DELETE FROM listing WHERE username=''" solution save all $username in array ... while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { $username = $row['username']; $u_names[] = $zsername; $link = $row['link']; ... and check for all $username in it if (isset($_POST['submit'])) { foreach($u_names as $usrname){ $item = (isset($_POST[$username])? $_POST[$username] : ''); if ($item == $username) { $query = "DELETE FROM listing WHERE username='$item'"; $result = mysql_query($query); if ((mysql_affected_rows() == 0) || mysql_affected_rows() == -1) { echo mysql_error(); echo 'error'; exit; } else echo "Deleted $item"; } } }
-
[SOLVED] Help with foreach() multidimensional array
sasa replied to xander85's topic in PHP Coding Help
change if(!isset($_SESSION['box'])) { $CartItem = array ($_SESSION['firstname'], $_SESSION['lastname'], $_SESSION['id']); $_SESSION['box'] = $CartItem; } else { $CartItem = array ($_SESSION['firstname'], $_SESSION['lastname'], $_SESSION['id']); array_push($_SESSION['box'], $CartItem); } to $_SESSION['box'][] = array ($_SESSION['firstname'], $_SESSION['lastname'], $_SESSION['id']); -
try $getvid = preg_replace('/<\s*style.+?<\s*\/\s*style.*?>/si', ' ', $getvid );