Web Development Questions That Don't Need Their Own Thread v2
3,079 replies, posted
[QUOTE=Alcapwne;31649164]I have a table in which one field has integer values. I need to fetch the largest one of those values, here's what I've tried:
[php]
$con = mysql_connect($hostname,$username,$password);
mysql_select_db('wc', $con);
$max = mysql_query('SELECT MAX( d8 ) FROM polls');
$date = mysql_fetch_array($max);
$d8 = $date['d8'];
echo $d8;
[/php]
but it doesn't return anything, can anyone help?
thanks[/QUOTE]
Try
[php]
$con = mysql_connect($hostname,$username,$password);
mysql_select_db('wc', $con);
$max = mysql_query('SELECT MAX( d8 ) FROM polls');
while($get = mysql_fetch_assoc($max)){
$d8 = $get['d8'];
}
echo $d8;
[/php]
[QUOTE=Lequinx;31649321]Try
[php]
$con = mysql_connect($hostname,$username,$password);
mysql_select_db('wc', $con);
$max = mysql_query('SELECT MAX( d8 ) FROM polls');
while($get = mysql_fetch_assoc($max)){
$d8 = $get['d8'];
}
echo $d8;
[/php][/QUOTE]
That doesn't work either :(
Meh, I tried
[QUOTE=Alcapwne;31649164]I have a table in which one field has integer values. I need to fetch the largest one of those values, here's what I've tried:
[php]
$con = mysql_connect($hostname,$username,$password);
mysql_select_db('wc', $con);
$max = mysql_query('SELECT MAX( d8 ) FROM polls');
$date = mysql_fetch_array($max);
$d8 = $date['d8'];
echo $d8;
[/php]
but it doesn't return anything, can anyone help?
thanks[/QUOTE]
Obligatory "use PDO" post; I'm pretty sure you've seen why many times.
[php]
$con = mysql_connect($hostname,$username,$password);
mysql_select_db('wc', $con);
$max = mysql_query('SELECT MAX( d8 ) FROM polls');
$date = mysql_fetch_row($max);
$d8 = $date[0];
echo $d8;
[/php]
Anyways, that should work
[QUOTE=deadeye536;31650518]Obligatory "use PDO" post; I'm pretty sure you've seen why many times.
[php]
$con = mysql_connect($hostname,$username,$password);
mysql_select_db('wc', $con);
$max = mysql_query('SELECT MAX( d8 ) FROM polls');
$date = mysql_fetch_row($max);
$d8 = $date[0][0];
echo $d8;
[/php]
Anyways, that should work[/QUOTE]
That works, thanks!
Also, I always thought PDO's main use was when you need to use prepared statements, no?
One more thing, how do I use a variable within a MySQL query again? I wanna do this:
[php]$info = mysql_query("SELECT name, options FROM polls WHERE d8 = $d8 ");[/php]
Should I put the query into a variable, and then run the mysql_query on that variable?
Thanks again
[editline]s[/editline]
Don't worry, I got it:
[php]$info = mysql_query("SELECT name, options FROM polls WHERE d8 = ".$d8." ");[/php]
[QUOTE=Alcapwne;31650728]That works, thanks!
Also, I always thought PDO's main use was when you need to use prepared statements, no?[/QUOTE]
For small scripts like this, it's not essential to use PDO, but it's always nice to get into the habit of using PDO for larger projects. I assumed that this is likely going to become part of something bigger.
[QUOTE=deadeye536;31650806]For small scripts like this, it's not essential to use PDO, but it's always nice to get into the habit of using PDO for larger projects. I assumed that this is likely going to become part of something bigger.[/QUOTE]
Yeah I'm gonna have to do a lot more scripts
[QUOTE=Alcapwne;31650728]That works, thanks!
Also, I always thought PDO's main use was when you need to use prepared statements, no?
One more thing, how do I use a variable within a MySQL query again? I wanna do this:
[php]$info = mysql_query("SELECT name, options FROM polls WHERE d8 = $d8 ");[/php]
Should I put the query into a variable, and then run the mysql_query on that variable?
Thanks again
[editline]s[/editline]
Don't worry, I got it:
[php]$info = mysql_query("SELECT name, options FROM polls WHERE d8 = ".$d8." ");[/php][/QUOTE]
If you're only tossing $d8 back into the query, can't you just use "SELECT d8, name, options FROM polls ORDER BY d8 DESC LIMIT 1" as your query, and get everything you need from it?
[QUOTE=deadeye536;31651188]If you're only tossing $d8 back into the query, can't you just use "SELECT d8, name, options FROM polls ORDER BY d8 DESC LIMIT 1" as your query, and get everything you need from it?[/QUOTE]
Ah nice, I didn't know you could do things like that, that is a lot more efficient
thanks!
[editline]10th August 2011[/editline]
Okay, is there any way I can merge 2 strings together to form a variable name, if you know what I mean?
for example:
[php]$i = 1;
$o1 = x;
$o2 = y;
$o3 = z;
while($i <= 3){
echo $(o$i); // I have no idea how I would do this
$i++;
}
[/php]
I want to echo $o1 the first loop, $o2 the second loop and $o3 the third loop, so can I sort of add the value of $i onto the end of the string 'o' and make that a variable?
HTML Dog says that I shouldn't use tags such as <b> but <strong> instead, should I use <strong> or CSS? Is <strong> and other similar tags like <em> considered presentational? Or cam I style these tags using CSS? Sorry if my question is unintelligible.
[QUOTE=Alcapwne;31651346]Ah nice, I didn't know you could do things like that, that is a lot more efficient
thanks!
[editline]10th August 2011[/editline]
Okay, is there any way I can merge 2 strings together to form a variable name, if you know what I mean?
for example:
[php]$i = 1;
$o1 = x;
$o2 = y;
$o3 = z;
while($i <= 3){
echo $(o$i); // I have no idea how I would do this
$i++;
}
[/php]
I want to echo $o1 the first loop, $o2 the second loop and $o3 the third loop, so can I sort of add the value of $i onto the end of the string 'o' and make that a variable?[/QUOTE]
A for loop might be better in this case, anyways, this should work.
[php]$o1 = 'hi';
$o2 = 'bye';
$o3 = 'foo';
for ($i = 1; $i <= 3; $i++) {
echo ${'o'.$i}; // I have no idea how I would do this
}[/php]
[editline]10th August 2011[/editline]
[QUOTE=Oppenheimer;31652201]HTML Dog says that I shouldn't use tags such as <b> but <strong> instead, should I use <strong> or CSS? Is <strong> and other similar tags like <em> considered presentational? Or cam I style these tags using CSS? Sorry if my question is unintelligible.[/QUOTE]
Most browsers will apply styles to those elements (bold to <strong>, and italics to <em>), but you can define styles to them yourself. The main purpose of those elements are as they're named, <em> provides emphasis, and <strong> makes something stand out; the default styling just helps to achieve this.
[QUOTE=deadeye536;31653310]A for loop might be better in this case, anyways, this should work.
[php]$o1 = 'hi';
$o2 = 'bye';
$o3 = 'foo';
for ($i = 1; $i <= 3; $i++) {
echo ${'o'.$i}; // I have no idea how I would do this
}[/php]
[editline]10th August 2011[/editline]
Most browsers will apply styles to those elements (bold to <strong>, and italics to <em>), but you can define styles to them yourself. The main purpose of those elements are as they're named, <em> provides emphasis, and <strong> makes something stand out; the default styling just helps to achieve this.[/QUOTE]
That works great! You're my hero [img]http://www.facepunch.com/fp/ratings/heart.png[/img]
Just installed microsoft visual web developer so I can play around with asp.net but for some reason it create a standard page with a premade login system and design, how can I remove all of that and just have a empty page ?
[QUOTE=deadeye536;31653310]
Most browsers will apply styles to those elements (bold to <strong>, and italics to <em>), but you can define styles to them yourself. The main purpose of those elements are as they're named, <em> provides emphasis, and <strong> makes something stand out; the default styling just helps to achieve this.[/QUOTE]
So should I use the tags or should I style it with CSS? Or doesn't it matter? Thank you for answering.
[QUOTE=quincy18;31654054]Just installed microsoft visual web developer so I can play around with asp.net but for some reason it create a standard page with a premade login system and design, how can I remove all of that and just have a empty page ?[/QUOTE]
While you're creating a new project, just select "Empty" on the template selection window,
[img]http://i.imgur.com/AgQOT.png[/img]
[QUOTE=quincy18;31654054]Just installed microsoft visual web developer so I can play around with asp.net but for some reason it create a standard page with a premade login system and design, how can I remove all of that and just have a empty page ?[/QUOTE]
obligatory i hope you're using mvc and not webforms post
[QUOTE=Oppenheimer;31654055]So should I use the tags or should I style it with CSS? Or doesn't it matter? Thank you for answering.[/QUOTE]
If the text is supposed to stand out, use <strong>, if you want to emphasise something use <em>. The tags have meanings, plain CSS doesn't.
[url=http://stackoverflow.com/questions/7012042/ie8-jquery-carousel-changing-item-width-with-javascript]Just gonna drop this here too[/url]
Has anyone ever encountered anything similiar?
[QUOTE=Skorpy;31663346][url=http://stackoverflow.com/questions/7012042/ie8-jquery-carousel-changing-item-width-with-javascript]Just gonna drop this here too[/url]
Has anyone ever encountered anything similiar?[/QUOTE]
Looks like IE8 is failing to redraw.
This is a very ugly solution, but it's the only one I could come up with.
[code] $(".item", $pane).click(function() {
$t = $(this);
if ($t.width() == startw) {
$t.animate({width:700}, 200);
} else {
$t.animate({width:startw}, 200);
}
window.setTimeout(function() {
if ($.browser.msie&&$.browser.version.slice(0,1)=="8") {
$('.item').each(function() {
this.style.cssText = this.style.cssText;
});
}
}, 205);
});[/code]
[QUOTE=deadeye536;31663905]Looks like IE8 is failing to redraw.
This is a very ugly solution, but it's the only one I could come up with.
[code] $(".item", $pane).click(function() {
$t = $(this);
if ($t.width() == startw) {
$t.animate({width:700}, 200);
} else {
$t.animate({width:startw}, 200);
}
window.setTimeout(function() {
if ($.browser.msie&&$.browser.version.slice(0,1)=="8") {
$('.item').each(function() {
this.style.cssText = this.style.cssText;
});
}
}, 205);
});[/code][/QUOTE]
Thaaaaaaank you!
Don't really care if it is a little ugly. IE can go fuck itself.
[QUOTE=Skorpy;31664036]Thaaaaaaank you!
Don't really care if it is a little ugly. IE can go fuck itself.[/QUOTE]
No problem! Most of the credit should go [url=http://www.telerik.com/community/forums/aspnet-ajax/scheduler/ie8-redraw-problem.aspx]here[/url], I just adapted it for your code.
Also, worth noting that it does not work in the callback for reasons unknown. So I just settled with 205 to ensure that the animation is complete.
Could someone please suggest me some fonts or give other tips about making my menu more readable (something that doesn't mess with your eyes as much)?
The difference in the text styles and fonts is because I've tried many different ones. They all will be the same font and style once I find a good solution.
[IMG]http://www.upload.ee/image/1570081/clipboard_upped.png[/IMG]
The menubar is the blue bar at the left.
If you want to make it more readable try not putting it on the left like that lol.
[QUOTE=KmartSqrl;31669135]If you want to make it more readable try not putting it on the left like that lol.[/QUOTE]
I knew it would come to this - but top is too mainstream.
If you're doing something a certain way just to be different when you're designing a website you're doing it wrong.
Hipsters are too mainstream.
[QUOTE=KmartSqrl;31669264]If you're doing something a certain way just to be different when you're designing a website you're doing it wrong.[/QUOTE]
You're right - I'll re-think the design.
[QUOTE=Chesnut;31669406]You're right - I'll re-think the design.[/QUOTE]
Not that there's anything wrong with doing things differently, but make sure you're never sacrificing usability if you don't need to be.
I am currently in the process of making a website where users will be able to upload images, name it and all that. Only I can't pay for hosting so my 'only' solution would be to turn to an external host, which I have nothing against. But I don't know which one to use, something like the [url=http://www.anyhub.net/page/api]anyhub API[/url] would be perfect. Does anyone know one?
[QUOTE=commander204;31669902]I am currently in the process of making a website where users will be able to upload images, name it and all that. Only I can't pay for hosting so my 'only' solution would be to turn to an external host, which I have nothing against. But I don't know which one to use, something like the [url=http://www.anyhub.net/page/api]anyhub API[/url] would be perfect. Does anyone know one?[/QUOTE]
imgur have an api which is probably much more widely used than anyhub's so they will have more support etc.
Sorry, you need to Log In to post a reply to this thread.