adsegzy
Members
-
Joined
-
Last visited
Reputation Activity
-
This query should work:
SELECT * FROM products WHERE status=1 ORDER BY package DESC, RAND() -
adsegzy got a reaction from NOCK in How to send Mail to email addresses in mysql tableThanks Friend,
I have sorted it out
-
adsegzy got a reaction from Kaskhautual in How do I update a json file with mysql data using phpHello friends,
I am knowledgeable in PHP but not in JSON. But I have a JSON script that I want some of the data in it to be dynamic from mysql database. I have products page where all products are listed, on clicking any product it opens product detail page where this JSON script coordinates. Below is d JSON file
My problems are how to make the below parts dynamic from mysql database (probably using PHP)
Thanks
-
mysql_query & mysqli_query are two similar but different functions. reading the W3 pages for each of the functions, there are some things you should notice
1. how you connect is different.
1a.) mysql_query needs to connect with a mysql_connenct command
1b.) mysqli_query needs to connect with a mysqli_connect command
2. what each function does and what they return are different
2a.) mysql_query performs a query on the data base and returns a handle of the query
2b.) mysqli_query performs a query against the data base(why different words on/against I don't know) and it will return -> For successful SELECT, SHOW, DESCRIBE, or EXPLAIN queries it will return a mysqli_result object. For other successful queries it will return TRUE. FALSE on failure
so you see they are different and can not be used interchangeably without some kind of function to clamp the data in way that each function could use.
for more information about the two functions you can read more at W3 on mysql_query and mysqli_query.
Also if you want to get a bigger grasp on the mysqli functions and how it all works together W3 has a reference page for that as well.
EDIT: corrected syntax and spelling errors and added some resource links.
-
one way i think may work for you is to use Jquery onchange
http://api.jquery.com/change/
from there you can use Jquery Ajax to post the drop down value to another file containing your select query to fetch the correct states to populate your select drop down options
http://api.jquery.com/jQuery.post/
hope it helps
-
You can do it with Ajax. Ajax is the fusion between Javascript and PHP, and maybe MySQL (if is really necesary).
<html> <head> <script type="text/javascript" language="javascript" src="jquery.js"></script> <script type="text/javascript" language="javascript"> function cambiar(dato) { $.ajax({ url: "cambiarEcho.php", async:true, contentType: "application/x-www-form-urlencoded", data: "value="+dato, dataType: "html", global: true, cache: false, ifModified: false, processData:true, success: function(datos) { document.getElementById('lugarDeCambio').innerHTML=datos; }, timeout: 3000, type: "GET" }); } </script> </head> <body> <div id="lugarDeCambio"> <?php echo $eventoElegido; ?> </div> <select name="evento" onclick="cambiar(this.value)"> <option value="1">Option A</option> <option value="2">Option B</option> </select> </body> </html>
cambiarEcho.php:
switch($_GET['value']) { case 1: echo "Option A"; break; case 2: echo "Option B"; break; }
-
Without refreshing the page, you'll need JavaScript.
A quick/dirty method would be to code all your forms, and wrap them in their own container, like so;
<div id="wedding-form" class="hidden-form"> <form action="" method="post"> <input type="text" name="flower_colour" value="Colour" /> <input type="text" name="surname" value="Surname" /> </form> </div> <div id="birthday-form" class="hidden-form"> <form action="" method="post"> <input type="text" name="age" value="Age" /> <input type="text" name="surname" value="Surname" /> </form> </div> <!-- ... etc. -->
Then listen to the Event Type 'change' event, and handle it. Something like:
$(document).ready(function(){ $("#event-type").change(function(){ switch ($(this).val().toLowercase()){ case 'wedding': $("#wedding-form").show(); break; case 'birthday': $("#birthday-form").show(); break; default: alert("Invalid choice!"); break; } }); //Hide all forms on page load $(".hidden-form").hide(); });
You'll need to use something like this for the Event Type HTML:
<select name="event_type" id="event-type"> <option value="Wedding">Wedding</option> <option value="Birthday">Birthday</option> </select>
And make sure you include jQuery, too.
Edit: I've just written this out on the forum so there may be bugs.
-
adsegzy reacted to SniderDK in I need a business social network software/scriptsyou want dolphin social network script (http://www.boonex.com/dolphin)... the source is open source which is a massive help
-
adsegzy reacted to Lovelock in I need a business social network software/scriptsBuddyPress for wordpress...
and your doing this as a school project? damn i never did anything like this
-
adsegzy reacted to Cabbage in apostrophe problem in my form fieldEnsure that magic quotes is turned off in your PHP config, they're not as evil as everybody makes them out to be but it's easier to find problems if they're off as you won't get slashes being added and taken away seemingly "magically".
Personally (among other things) I make my SQL queries safe (and avoid the headache with slashes) by using something similar to the following.
Inserting to a database
$dbVar = addslashes($var);
Retrieving from a database
echo stripslashes($dbVar);
Try to limit what users can enter into forms too, lock it down where possible and never rely on client-side validation.
-
adsegzy reacted to webdeveloper93 in apostrophe problem in my form fieldWhen u display it from the database try running it through stripslashes or when displaying it try this
$variable = str_replace("/","",$row['something']);
EDIT: also are u sure its forward slashes ur getting and not back slashes i've never got forward slashes before but anyways if its backslashes just change the code above to,
$variable = str_replace("\","",$row['something']);
-
adsegzy reacted to j05hr in apostrophe problem in my form fieldYou can use str_replace in your code so you would do something like
$variable = str_replace (",", "", $_POST['whatever']);
There might be a better way to do it than the way I have done it as I'm no pro with PHP myself (Assuming it is PHP you are doing it in)
Here it is in the PHP manual
http://php.net/manual/en/function.str-replace.php
-
adsegzy reacted to Jay Gilford in Numeric Directory Search problem$sql = mysql_query("SELECT * FROM $com_name WHERE com_name REGEXP '^[0-9]'");
-
adsegzy reacted to Jock in problem with table in my php mailYou're probably sending it as plain text.
-
http://www.tech-recipes.com/rx/1492/php-rename-or-move-a-file-on-the-server/ -
adsegzy reacted to Tangled Frog in resize image problemHi there,
You might like to try using something like this instead, it should do the trick if you're using PHP 5:
$originalImage = $_FILES['image']['tmp_name']; $src = imagecreatefromjpeg($originalImage); list($width,$height) = getimagesize($originalImage); $ratio = $width/$height; if ($width > $height) {if ($width > 300) {$new_height = 300 / $ratio; $new_width = 300;} else {$new_height = $height; $new_width = $width;}} else {if ($height > 300) {$new_width = 300 * $ratio; $new_height = 300;} else {$new_height = $height; $new_width = $width;}} $target = "upload/image.jpg"; $tmp = imagecreatetruecolor($new_width,$new_height); imagecopyresampled($tmp,$src,0,0,0,0,$new_width,$new_height,$width,$height); imagejpeg($tmp,$target,100);
This will resize your image to a maximum of 300px while retaining the original dimensions.
If you're still having problems the manual for GD library is very helpful and not too hard to understand.
Hope it works out ok!
Kirsty
-
adsegzy reacted to zed in resize image problemor use timthumb? http://www.binarymoon.co.uk/projects/timthumb/
works a treat.
-
adsegzy reacted to Ashley Byrom in How to echo out 3 column tableYou can put any HTML in an echo statement so long as you escape any funky characters...
<table> <tr><td>Hello 1</td></tr> <tr><td>Hello 2 </td></tr> <tr><td>Hello 2</td></tr> </table>
Becomes
<?PHP echo "<table> <tr><td>Hello 1</td></tr> <tr><td>Hello 2 </td></tr> <tr><td>Hello 2</td></tr> </table>";
Make sure you put a \ before any double quotes in your HTML to escape them
-
adsegzy reacted to empek in How to echo out 3 column table -
adsegzy reacted to dt17 in How to echo out 3 column tablelol'd
-
adsegzy reacted to empek in How to echo out 3 column tableHere's a link to a tutorial I wrote for you.
-
adsegzy reacted to Lev in different style for different hyperlinksYou also can use it:
<style type="text/css"> a {color: #3366FF;} a:hover {color:#FFCC66} .red a {color: #FFF; background: #F00;} .red a:hover {color: #00F; background: #F00;} </style> <div>It is a <a href="">Hyperlink</a></div> <div class="red">It is a <a href="">Hyperlink</a>. It is a <a href="">Hyperlink</a>.</div>
-
adsegzy reacted to andy9l in different style for different hyperlinksCSS:
/* For hyperlinks without background */ a, a:visited{ color: blue; /* Colour of hyperlink text */ } a:hover, a:visited:hover{ color: red; /* Colour of hovered text */ } /* For hyperlinks with background */ a.bg, a.bg:visited{ color: blue; /* Colour of hyperlink text */ background: red; /* Colour of background */ } a.bg:hover, a.bg:visited:hover{ color: red; /* Colour of hovered text */ background: blue; /* Colour of hovered background */ }
HTML
<a href="#" title="Hyperlink title">This hyperlink will not have a background</a> <a href="#" title="Hyperlink title" class="bg">This hyperlink will have a background</a>
The colours are horrible, but you get the idea
-
adsegzy reacted to Lev in how do i make a cell to be a linkEZest way is:
<!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=windows-1251" /> <title>Untitled Document</title> </head> <body> <script> function lnk(param) { window.location.href = "http://www.yourSite.name/" + param; } </script> <table width="200" height="128" border="0" cellpadding="5" cellspacing="0"> <tr> <td onclick="lnk('home')">Home</td> </tr> <tr> <td onclick="lnk('about')">Abour Us</td> </tr> <tr> <td onclick="lnk('contact')">Contact</td> </tr> </table> </body> </html>
But esteemed Connectu_C is dnmnd right — it is a thousand times better to use UL instead of TABLE to create CSS menu.
-
adsegzy reacted to webdeveloper93 in problem with my text area fieldTry using n12br();