PravinS
Members-
Posts
459 -
Joined
-
Last visited
-
Days Won
2
Everything posted by PravinS
-
Try this <?php $k = 1; while () // your while loop { // your code if ($k % 5 == 0) echo "<br>"; $k++; } ?>
-
Are you getting some error?
-
How to get text from a drop down selection into a text field
PravinS replied to spenceddd's topic in PHP Coding Help
Use this[this.selectedIndex].text Instead of this[this.selectedIndex].value -
How can I force a file to download instead of opening
PravinS replied to HGeneAnthony's topic in PHP Coding Help
You can use this function function force_download($file) { $dir = ""; if ((isset($file))&&(file_exists($dir.$file))) { header("Content-type: application/force-download"); header('Content-Disposition: inline; filename="' . $dir.$file . '"'); header("Content-Transfer-Encoding: Binary"); header("Content-length: ".filesize($dir.$file)); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . $file . '"'); readfile("$dir$file"); } } -
If "RY" is given, select all where it starts with RY
PravinS replied to phatuis's topic in PHP Coding Help
Use SQL query like this. SELECT * FROM tbl_name WHERE key_col LIKE 'RY%'; -
How will you get $row['id']?
-
Your delete query is wrong, you have used $ in where condition for field name. Use below given query. $query = "DELETE FROM recipes WHERE id = '$id'";
-
While inserting data in the table use MYSQL NOW() function to insert date, and while retrieving it from database use MYSQL DATE_FORMAT() function.
-
Also add enctype="multipart/form-data" for form.
-
First echo is commented and second is blank.
-
What method you are using in form POST or GET?
-
You need to create database on new server and upload the database from old server. Create database dump(.sql) file from old server and upload it to new server. Then in cms_class.php page update username, password, database name of new server.
-
Does image.gif physically exists in images folder?
-
Use below given functions function select_row($sql) { //echo $sql . "<br />"; if ($sql!="") { $result = mysql_query($sql) or die("Error: ".mysql_errno().":- ".mysql_error()); if ($result) { while($row = mysql_fetch_assoc($result)) $data[] = $row; } return $data; } } function pagingSlot($sql, $recperpage, $pagesetlimit, $page, $class, $getvars) { $rescnt=mysql_query($sql); $totcnt=mysql_num_rows($rescnt); if (!$page) $page = 1; $first=(($page-1)* $recperpage); $sql = $sql . " limit ".$first.",".$recperpage; $res = select_row($sql); $serial_no = ($page - 1) * $recperpage; $t = ($totcnt/$recperpage); $arr=split('[.]',$t); if ($arr[1]) $totalpages=$arr[0]+1; else $totalpages=$arr[0]; if ($totalpages > $pagesetlimit) { if ($page > 1) $pagesetstart = $page - 1; else $pagesetstart = $page; $pagesetend= ($pagesetstart-1) + $pagesetlimit; if ($pagesetend > $totalpages) { $pagesetend = $totalpages; $pagesetstart = $pagesetend - $pagesetlimit + 1; } } else { $pagesetstart = 1; $pagesetend = $totalpages; } $str = ""; if ($page > 1) { $prev = $page - 1; $str.= "<a href='".$_SERVER['PHP_SELF']."?page=$prev".$getvars."' class='".$class."'> << </a> | "; } else { $str.= "<< | "; } for ($i=$pagesetstart; $i<=$pagesetend; $i++) { if ($i <= $totalpages) { if (!$page) $page=1; if ($page==$i) $str.= '<font color=red>'.$i.'</font> '; else $str.= "<a href='".$_SERVER['PHP_SELF']."?page=$i".$getvars."' class='".$class."'>".$i."</a> "; } } if ($page < $totalpages) { $next = $page + 1; $str.= " | <a href='".$_SERVER['PHP_SELF']."?page=$next".$getvars."' class='".$class."'> >> </a> "; } else { $str.= " | >> "; } if ($totcnt == 0) $str = ""; $arr["records"]=$res; $arr["link"]=$str; $arr["serial"]=$serial_no; return $arr; }
-
Inserting the current date/time while submitting the forum
PravinS replied to atrocious's topic in PHP Coding Help
Use like this mysql_query("update application set comment='".mysql_real_escape_string($_POST[comment])."', userdatetime = NOW() where `IGN`='".mysql_real_escape_string($_POST[name])."'"); -
Inserting the current date/time while submitting the forum
PravinS replied to atrocious's topic in PHP Coding Help
remove the (') single quotes, use only NOW() function. Also why are you using 2 different queries to update same table. You can do it in single update query. -
Inserting the current date/time while submitting the forum
PravinS replied to atrocious's topic in PHP Coding Help
You have not used mysql_query() function for insert query $sql= mysql_query("INSERT INTO application (datetime) VALUES (NOW())"); -
Hi Please use below given function function pagingPN($sql, $page, $limit, $getvars, $class) { if ($page == "") $page = 1; if ($limit == 0) $limit = $this->limit; $tsql = $sql; $result = mysql_query($tsql) or die("Error: ".mysql_errno().":- ".mysql_error()); $total = mysql_num_rows($result); $totnumpages = ceil($total/$limit); if ($offset < 0) $offset = 0; else $offset = ($page - 1) * $limit; $sql = $sql. " limit $offset, $limit"; if ($sql!="") { $result = mysql_query($sql) or die("Error: ".mysql_errno().":- ".mysql_error()); if ($result) { while($row = mysql_fetch_array($result)) $data[] = $row; } $res = $data; $serial_no = ($page - 1) * $limit; if ($total > 0) { $link .= "<font face='verdana' size='1'>Page: <strong>".$page."</strong> of <strong>".$totnumpages."</strong> Goto: </font>"; if ($page > 1) { $link .= "<a href=".$_SERVER['PHP_SELF']."?page=1$getvars class='".$class."' title='Jump to First Page'><<</a> | "; $prev = $page - 1; $link .= "<a href=".$_SERVER['PHP_SELF']."?page=".$prev."$getvars class='".$class."' title='Goto Previous Page'>Previous</a><span class='".$class."'> | </span>"; } else { $link .= "<span class='".$class."' title='Jump to First Page'><<</span> | <span class='".$class."' title='Goto Previous Page'>Previous | </span>"; } if ($page < $totnumpages) { $next = $page + 1; $link .= "<a href=".$_SERVER['PHP_SELF']."?page=".$next."$getvars class='".$class."' title='Goto Next Page'>Next</a> | "; $link .= "<a href=".$_SERVER['PHP_SELF']."?page=".$totnumpages."$getvars class='".$class."' title='Jump to Last Page'>>></a>"; } else { $link .= "<span class='".$class."' title='Goto Next Page'>Next</span> | <span class='".$class."' title='Jump to Last Page'>>></span>"; } } $retarr["sql"] = $sql; $retarr["records"] = $res; $retarr["serial_no"] = $_no; $retarr["link"] = $link; return $retarr; } } $rs = pagingPN($query, trim($_REQUEST['page']), 10, "", "pagingCSS"); $rs_recordset = $rs['records']; $link = $rs['link'];
-
Oh I am really sorry
-
I have not insisted to use array($res) in the code.
-
Use for loop like this, replace fieldnam1, fieldname2 .... with your table fieldnames for($i=0;$i<count($res);$i++) { echo $res[$i]['fielname1']." ".$res[$i]['fielname1']; }
-
Use like this $res = select_row("SELECT * from mains order by main_id asc limit 10 "); echo "<pre>"; print_r($res); echo "</pre>";
-
Use below given function, it will give you 2 dimension array function select_row($sql) { $rs = mysql_query($sql); if (!$rs) return false; else { while($row = mysql_fetch_array($rs,MYSQL_ASSOC)) { $res[] = $row; } return $res; } }
-
Please close PHP tag ( ?> ) at the end of the code.
-
[SOLVED] data not passing through $_POST....i think
PravinS replied to riceje7's topic in PHP Coding Help
You need to use enctype="multipart/form-data" for your form tag like this <form name="form1" method="post" action="register.php" enctype="multipart/form-data">