-
Posts
498 -
Joined
-
Last visited
Never
Everything posted by jesushax
-
hi could somone tell me why this brings up a mysql error please the error is cheers $max = 3; //amount of articles per page. change to what to want $p = @$_GET['p']; if(empty($p)) { $p = 1; } $limits = ($p - 1) * $max; //view all the news articles in rows $sql = mysql_query("SELECT * FROM tblNews LIMIT ".$limits.",".$max." ORDER BY NewsDateAdded DESC") or die(mysql_error()); //the total rows in the table $totalres = mysql_result(mysql_query("SELECT COUNT(NewsID) AS tot FROM tblNews"),0); //the total number of pages (calculated result), math stuff... $totalpages = ceil($totalres / $max); echo '<h3>News</h3>'; echo "<div style='text-align:center;'>View Page: "; for($i = 1; $i <= $totalpages; $i++){ //this is the pagination link echo "<a href='short_news.php?p=$i'>$i</a>|"; } echo "</div>"; $i = 0;
-
below is my code for my news, im trying to alternate the even rows so the image is on the left on them which is what ive done given the code you gave me, but whats happening is its just displaying the record1 twice on the page is this becuase of the pagnation code? cheers <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/header.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/inner-head.php'); $max = 3; //amount of articles per page. change to what to want $p = @$_GET['p']; if(empty($p)) { $p = 1; } $limits = ($p - 1) * $max; //view all the news articles in rows $sql = mysql_query("SELECT * FROM tblNews LIMIT ".$limits.",$max") or die(mysql_error()); //the total rows in the table $totalres = mysql_result(mysql_query("SELECT COUNT(NewsID) AS tot FROM tblNews"),0); //the total number of pages (calculated result), math stuff... $totalpages = ceil($totalres / $max); echo '<h3>News</h3>'; echo "<div style='text-align:center;'>View Page: "; for($i = 1; $i <= $totalpages; $i++){ //this is the pagination link echo "<a href='short_news.php?p=$i'>$i</a>|"; } echo "</div>"; while($news = mysql_fetch_array($sql)) { $i = 0; while ($row = mysql_fetch_assoc($sql)) { ++$i; if ($i % 2 == 0) // Here are your even records { echo '<div style="float:left; width:100%; margin-bottom:10px;">'; echo '<a href="fullstory.asp?id='.$news["NewsID"].'">'.$news["NewsTitle"]."</a>"; echo " - <i>"; echo $news["NewsDateAdded"]; echo "</i></div>"; if (!empty($news["NewsImage1"])) { echo '<div style="width:200px; float:left;">'; echo '<img style="border:1px dashed #666666;" src="/news/uploads/'.$news["NewsImage1"].' " alt=" '.$news["NewsImage1"].' " />'; echo '</div>'; } echo '<div style="width:70%; margin-right:10px; float:left; text-align:justify;">'; echo str_replace("\n", "<br />",$news["NewsShort"]); echo "</div>"; if (!empty($news["NewsAttachment"])) { echo "<div style=\"float:left; width:100%;\">Attachment"; echo '<a href="/news/uploads/'; echo $news ["NewsAttachment"].'" onclick="target=\'blank\';">'; echo $news ["NewsAttachment"]."</a></div>"; } echo '<div style="padding:10px 0; border-bottom:1px dashed #666666; float:left; width:100%; text-align:center; margin-bottom:30px;"><a href="/news/full_news.php?id='.$news["NewsID"].'">'."View the full story"."</a></div>"; } else // Here are your odd records { echo '<div style="float:left; width:100%; margin-bottom:10px;">'; echo '<a href="fullstory.asp?id='.$news["NewsID"].'">'.$news["NewsTitle"]."</a>"; echo " - <i>"; echo $news["NewsDateAdded"]; echo "</i></div>"; echo '<div style="width:70%; margin-right:10px; float:left; text-align:justify;">'; echo str_replace("\n", "<br />",$news["NewsShort"]); echo "</div>"; if (!empty($news["NewsImage1"])) { echo '<div style="width:200px; float:left;">'; echo '<img style="border:1px dashed #666666;" src="/news/uploads/'.$news["NewsImage1"].' " alt=" '.$news["NewsImage1"].' " />'; echo '</div>'; } if (!empty($news["NewsAttachment"])) { echo "<div style=\"float:left; width:100%;\">Attachment"; echo '<a href="/news/uploads/'; echo $news ["NewsAttachment"].'" onclick="target=\'blank\';">'; echo $news ["NewsAttachment"]."</a></div>"; } echo '<div style="padding:10px 0; border-bottom:1px dashed #666666; float:left; width:100%; text-align:center; margin-bottom:30px;"><a href="/news/full_news.php?id='.$news["NewsID"].'">'."View the full story"."</a></div>"; } } } echo "<div style='text-align:center; clear:both;'>View Page: "; for($i = 1; $i <= $totalpages; $i++){ //this is the pagination link echo "<a href='short_news.php?p=$i'>$i</a>|"; } echo "</div>"; include($_SERVER['DOCUMENT_ROOT'] . '/includes/inner-foot.php'); include($_SERVER['DOCUMENT_ROOT'] . '/includes/footer.php'); ?>
-
yes the second one is what im after having different code for differnt recrds, its all about displaying them differnt thanks!
-
hi was wonering how i can alternate code for records like records 1,3,5,7,9 have (THIS CODE) and records 2,4,6,8 have (THAT CODE) you know what i mean? thanks for help
-
tanks
-
hi i was wonderin ghow to do the above i want to only disaply acertain number of characters of a record then when it reaches a certain point put "..." anyoe know? cheers
-
hi what im after is something that shows where you are witin the website not folders, pages so the page says: You are In: About Us You are In About Us > Contact > Form sort of thing does anyoen know what i mean and where i can get this? thanks
-
hello again $sql = mysql_query("SELECT * FROM tblUsers WHERE UserEmail='".$Email."' ") or die(mysql_error()); $rspass = mysql_fetch_array($sql); i want to do write a the message email address does not exist if the query doesnt return any results any hints? cheers
-
if pass field blank dont update sql on the slected fields
jesushax replied to jesushax's topic in PHP Coding Help
just what the doctor order thankyou -
if pass field blank dont update sql on the slected fields
jesushax replied to jesushax's topic in PHP Coding Help
this is how it would work in asp i just dont know in php... SQL = "UPDATE table SET " _ & "UserName ='" & strUserName & "', " _ & "FirstName ='" & strFirstName & "', " if LEN(strUserPass ) > 0 AND not isnull(strUserPass ) then SQL = SQL & "UserPassword='" & strUserPass & "', " end if SQL = SQL & "UserEmail='" & StrUserEmail & "' " _ & "WHERE UserID=" & ID -
if pass field blank dont update sql on the slected fields
jesushax replied to jesushax's topic in PHP Coding Help
do i need two sql queries? cos i still want the sql to run if the user doesnt change their password if they dont change teh password i just want to not set UserPassword and still update the rest Cheers -
target blank is no longer valid xhtml, so if hes craeting his site to be valid hell need the javascript method
-
Inseting modified details back into database
jesushax replied to mikebyrne's topic in PHP Coding Help
you need to add some actions to yoru form to retrieve data heres a start <form method=post action="?edit"> use switch case switch(@$_GET["action"]) { Case "lostpass": code to retrive form dta and sql $ID= ($_POST["txtID"]); // Create hidden id text field for that record $strProdcutName= mysql_real_escape_string($_POST["txtProductName"]); //the txtProductName refers to your fieldname mysql_query("Update tblUsers Set ProductName='".$strProdcutName."' Where ProductID='".$ID."' ") or die(mysql_error()); break; default: your pages default code break; } -
here you go $content .="<td><a href='" .$result[photo]. "' onclick=\"window.open(this.href); return false;\"><img src='".$result[photo]."' width='".$width_of_thumb."' height='".$height_of_thumb."'><br><left>".$result[title]."<br></left></a></td>";
-
use onclick="window.open(this.href); return false;" is w3 valid, target blank no longer is...
-
if pass field blank dont update sql on the slected fields
jesushax posted a topic in PHP Coding Help
hi the code below updates a users password from a form, and what i need to do is if the filed password is left blank then the sql UserPassword is not run how can i do this? Cheers $strUserName = mysql_real_escape_string($_POST["txtUserName"]); $strFirstName = mysql_real_escape_string($_POST["txtFirstName"]); $strlastName = mysql_real_escape_string($_POST["txtLastName"]); $strTel = mysql_real_escape_string($_POST["txtTel"]); $strHomePage = mysql_real_escape_string($_POST["txtHomePage"]); $strCompanyName = mysql_real_escape_string($_POST["txtCompanyName"]); $strUserPass = md5($_POST["txtUserPass"]); $strEmail = mysql_real_escape_string($_POST["txtEmail"]); $strUserID = $_SESSION["UserID"]; if(!strlen($strUserName)){ echo '<p style="color:#FF0000;">Error: Username Was Left Blank</p>'; } elseif(!strlen($strEmail)){ echo '<p style="color:#FF0000;">Error: Email Was Left Blank</p>'; } else{ mysql_query("Update tblUsers Set UserName='".$strUserName."', UserPassword='".$strUserPass."', UserEmail='".$strEmail."', UserCompanyName='".$strCompanyName."', UserFirstName='".$strFirstName."', UserLastName='".$strlastName."', UserTel='".$strTel."', UserHomePage='".$strHomePage."' WHERE UserID='".$strUserID."'") or die(mysql_error()); -
hmmm i like the secret question idea... so i get them to answer the question then send them to a change password page sounds like a plan, about an hours work but i like it... cheers
-
i dont know wha tyou mean with your example discomatt.. :S
-
no that doesnt work either same error message as before it says near line 1 but line 1 isnt even sql the near 2 thing is the user id though i know the users id im trying to change is 2 and it says near 2 so somethings going wrong there...
-
i have this altogther now <?php include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); switch(@$_GET["action"]) { Case "lostpass": function createRandomPassword() { $chars = "abcdefghijkmnopqrstuvwxyz023456789"; srand((double)microtime()*1000000); $i = 0; $pass = '' ; while ($i <= 7) { $num = rand() % 33; $tmp = substr($chars, $num, 1); $pass = $pass . $tmp; $i++; } return $pass; } //end $Email = mysql_real_escape_string($_POST["txtEmailAddress"]); $sql = mysql_query("SELECT UserID FROM tblUsers WHERE UserEmail='".$Email."' ") or die(mysql_error()); $rspass = mysql_fetch_array($sql); $ID = $rspass["UserID"]; $password = createRandomPassword(); $Newpass = md5($password); mysql_query("UPDATE tblUsers SET UserPassword='".$Newpass." WHERE UserID='".$ID."'") or die(mysql_error()); // Usage echo "Your random password is: $password"; break; default: ?> <form name="lostpass" method="post" action="?action=lostpass"> <p> Your Email Address:<input name="txtEmailAddress" type="text" size="30"><br /> <input name="" type="submit" value="Send Password"> </p> </form> <p><a href="/includes/login_form.php class="lbOn"">Back to login form</a></p> <p><a href="#" class="lbAction" rel="deactivate">Close / Cancel</a></p> <?php break; } ?> and this error message ideas? cheers
-
im trying to resset a users password to password if they forget it im going wrong somewhere though include($_SERVER['DOCUMENT_ROOT'] . '/includes/connection.php'); switch(@$_GET["action"]) { Case "lostpass": $Email = mysql_real_escape_string($_POST["txtEmailAddress"]); $sql = mysql_query("SELECT UserID FROM tblUsers WHERE UserEmail='".$Email."' ") or die(mysql_error()); $rspass = mysql_fetch_array($sql); $ID = $rspass["UserID"]; mysql_query("UPDATE tblUsers SET UserPassword='". md5("password")." WHERE UserID='".$ID."'") or die(mysql_error()); is there a way i can set a users password to a random word then get that word emailed to them? CHeers
-
its cos my fiel size is 11318 which /1024 /1024 is 0.010.... how do i make it to 3 decimal places or how do i display it in kb instead? cheers
-
$FileSize = ($rsfiles["FileSize"] / 1024) / 1024; $exp_file = explode(".", $FileSize); $output = $exp_file[0].".".substr($exp_file[1],0,1); the above give me 0.
-
wait that does work, but is shows 0 as the result how can i make it displat decimal places the result is 0 but its something like 0.1 how do i make it do this? cheers