PravinS
-
Posts
459 -
Joined
-
Last visited
-
Days Won
2
Posts posted by PravinS
-
-
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.
-
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">
-
You can use mail class. I have attached the mail class file and copy below given code and set the values.
<?php $nameto = ""; $emailto = ""; $emailalt = ""; include_once("class.phpmailer.php"); $Mail = new PHPMailer(); $Mail->Mailer = "mail"; $Mail->SetLanguage("en",""); $Mail->IsHTML(true); $Mail->Priority = 3; $Mail->Encoding = "8bit"; $Mail->CharSet = "iso-8859-1"; $Mail->From = ""; $Mail->FromName = ""; $Mail->Sender = ""; $Mail->WordWrap = 0; $Mail->Body = ""; $Mail->Subject = "" ; $Mail->AddAddress($emailto,$nameto); $Mail->Send(); ?>
[attachment deleted by admin]
-
You can use below given code to paging
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"; $res = $this->select_row($sql); $serial_no = ($page - 1) * $limit; if ($total > 0) { $link = "<font face='verdana' size='1'>Page: <strong>".$page."</strong> of <strong>".$totnumpages."</strong> "; 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; }
It will give you << | Previous | Next | >> pagination.
Parameters of functions are
$sql = sql query
$page = page number(just use $_REQUEST['page'])
$limit = number of record on one page
$getvars = query string variables, if you want to pass anything
$class = CSS for the links
-
Use this
<?php function format_date($date) { $dtarr = explode("/",$date); return $dtarr[2]."-".$dtarr[1]."-".$dtarr[0]; } echo format_date("24/08/2009"); ?>
-
You have redirected the page, so it is not showing the field values.
Comment this line
//header("location:1.php");
-
$sql="SELECT market_id FROM cashier WHERE (cashier_name='$myusername' and cashier_id='$mypassword')"; $result=mysql_query($sql); $row = mysql_fetch_row($result); echo $row[0]; // will display market_id
-
Try this
$DB_site->query("UPDATE tbluserdetails set logged= 'Y', dtlogged='now()', timeslogged = timeslogged + 1 where username='$username'");
-
Upload on any php supporting server and check. SMTP is not configured on you local machine so u r getting that error
-
May this function will help you
function quote_smart($value)
{
// Stripslashes
if (get_magic_quotes_gpc())
{
$value = stripslashes($value);
}
// Quote if not a number or a numeric string
if (!is_numeric($value))
{
$value = "'" . mysql_real_escape_string($value) . "'";
}
return $value;
}
-
Hi All,
I want to integrate phpbb registration/login with my customised site.
Any idea.
Thanks in advance.
-
You have missed mysql_query() in this function
function countMessages($name) {
$id = getidbyName($name);
$res= mysql_query("SELECT * FROM private_messages WHERE owner_id = '$id'");
$num_rows = mysql_num_rows($res);
return $num_rows;
}
-
User asort(array) function
-
Use:
$quotelist = $_REQUEST['quotelist'];
$p = explode("$$", $quotelist);
for($i=1;$i<count($p);$i = $i++){
//(process info)
}
-
Please share your upload code here
-
Share your iframe code
-
I have used nested function to generate multilevel dynamic menu.
-
Use DATETIME data type for date field. You can INSERT date and time by using NOW() function in sql statement.
-
$newname = dirname(__FILE__).'/uploads/'.$filename;
-
Replace your <form tag with this
<form name="gallery" action="" method="post" enctype="multipart/form-data">
-
Try this PHP code for menu
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
<!--
.menutd
{
font-family: Verdana;
font-size: 11px;
color:#000000;
background-color:#FFFFFF;
cursor:pointer;
}
.menumainbg
{
background-color:#ECE9D8;
}
.menuhead
{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10px;
font-weight:bold;
height:20px;
cursor:pointer;
padding-top:5px;
}
.submenuhead
{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10px;
font-weight:bold;
height:20px;
cursor:pointer;
}
.menutr
{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10px;
font-weight:none;
background-color:#FFFFFF;
}
.menutr_over
{
font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10px;
font-weight:none;
background-color:#E3E9F1;
cursor:pointer;
}
-->
</style>
<script language="javascript">
function Toggle(id,len)
{
var obj=document.getElementById("adminmgmt"+id);
var visible=(obj.style.display != "none");
if (visible)
obj.style.display="none";
else
obj.style.display="block";
}
</script>
</head>
<body>
<table width="150" border="0" cellspacing="0" cellpadding="0" align="left">
<tr>
<td>
<table width="100%" border="0" cellspacing="1" cellpadding="2">
<?php
$adm_menu = array (1 => "Heading 1", "Heading 2", "Heading 2");
$adm_sub_menu =
array
(
1 =>
array(
1 => array("Google", "http://www.google.com"), array("Yahoo", "http://www.yahoo.com"), array("Rediff", "http://www.rediff.com")),
array(
1 => array("Orkut", "http://www.orkut.com"), array("Times", "http://www.indiatimes.com")),
array(
1 => array("ABC", "http://www.abc.com"))
);
for($mnu1=1;$mnu1<=count($adm_menu);$mnu1++)
{
?>
<tr>
<td align="left" valign="top" class="menumainbg">
<div onclick="javascript: Toggle(<?=$mnu1?>,<?=count($adm_menu)?>);" class="menuhead"><?=$adm_menu[$mnu1]?><?php if (count($adm_sub_menu[$mnu1]) > 0){?> »<?php } ?></div>
<div style="display:none;" id="adminmgmt<?=$mnu1?>">
<table width="100%" border="0" cellspacing="1" cellpadding="5">
<?php
for($mnu2=1;$mnu2<=count($adm_sub_menu[$mnu1]);$mnu2++)
{
?>
<tr>
<td class="menutr" onclick="javascript: window.location='<?=$adm_sub_menu[$mnu1][$mnu2][1]?>';" onmouseover="this.className='menutr_over';" onmouseout="this.className='menutr';"><?=$adm_sub_menu[$mnu1][$mnu2][0]?></td>
</tr>
<?php
}
?>
</table>
</div>
</td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>
Mysql query in an Array
in PHP Coding Help
Posted
I have not insisted to use array($res) in the code.