alexguz79
-
Posts
38 -
Joined
-
Last visited
Never
Posts posted by alexguz79
-
-
Hey everybody, i'm building a website for the softball league i play in.... so far the website is pretty good... with all the stats and profiles.... i'm having a little problem with the ORDER of the leaders in the categories i have to calculate the result...
for example... avg. is the result of the total hits divided by the total number of at bats... both numbers are coming from the database... the problem comes when i have to order the leaders from first to last...
this is my php:
$sql = "select profile_id, SUM(total_hits) AS hitstotal, SUM(ab) AS abtotal from batters WHERE year = '2010' GROUP BY profile_id"; $cons = mysql_query($sql); while ($result = mysql_fetch_array($cons)) { $sumaab = $resultad['abtotal']; $sumahits = $resultad['hitstotal']; $p_id = $resultad['profile_id']; $prom = round(($sumahits."") / ($sumaab.""),3);
that gives me all the batting averages for the players.
and here is my question:
how can i order that $prom result from first to last?
-
Hey everybody...
i am creating a website for the softball league i play in... and i have the batting average display with this code:
echo round(($totalhits."") / ($abs.""),3)
that takes the total hits and the total at bats and give me the average... the 3 is to limit the result to 3 figures insted of all the numbers in case of 0.333333333
the thing is i want to eliminate the 0 at the left of the dot... so it displays .333 insted of 0.333
the other thing is i want to display the complete number in case it's a round one... .400 insted of .4
thanks
-
thanks... i'll try that
-
Greetings!!!
I know if i want the SUM of al the values in a row i jus do 'SELECT SUM(row) AS row_total FROM table'
but how about if i want to substract the values? ex: 2-2-3-1-4
what should i use?
thanks
-
anyone please
-
Hey...
Hope you can help me on this one:
I have a menu witch information is stored in a database, i can get the info to load the problem is insted of giving me a dropdown menu with 10 options, is giving me 10 dropdown menus with 1 option
here's the code
<label> <select name="players" id="players"> <option value="<?php $id; ?>"><?php echo $fname; ?> <?php echo $lname; ?></option> </select> </label>
-
the ROUND worked ... it was so easy.. thanks
-
Hey everybody...
i have this peace of code that gime me an average between total_hits and atBats (i'm working a baseball league website) but the thing echo all the numbers after the decimal dot... i just want tree... ex: is giving me 0.666666666667 and i could use better .666
anyone knows how to get me there?
here's the code:
<? $sql5="select total_hits from bateadores_locales WHERE profile_id ='$id' && year = '2010'"; $cons5=mysql_query($sql5); while($resultado5=mysql_fetch_array($cons5)) $suma5+=$resultado5['total_hits']; ?><? $sql6="select ab from bateadores_locales WHERE profile_id ='$id' && year = '2010'"; $cons6=mysql_query($sql6); while($resultado6=mysql_fetch_array($cons6)) $suma6+=$resultado6['ab']; echo (($suma5."") / ($suma6."")) ?>
thanks
-
steveangelis not sure if i understand what your are saying... what am idoing wrong?
-
Hey everybody...
i have this problem:
i have my comment system working in terms of adding and displaying the data... but there's this thing that everytime the page loads insert a new blank field in the database... here's the code... thank in advance
<form action="<?=$PHP_SELF?>" method="post"> Nombre:<br /> <input type="text" name="name" id="name" /> <br /> Commentario:<br /> <input type="text" name="comment" id="comment" /> <br /> <input type="submit" value="Enviar" /></form> <?php mysql_connect("localhost", "root", "root") or die(mysql_error()); mysql_select_db("gallery") or die(mysql_error()); $id = $_GET['id']; $result2 = mysql_query("SELECT * FROM images_comments WHERE image_id = '$id' ORDER BY ID DESC"); $sql="INSERT INTO images_comments (id, image_id, name, comment) VALUES ('','$id','$_POST[name]','$_POST[comment]')"; !mysql_query($sql); ?>
-
anyone please
-
Greeting everyone...
The issue is this...
i have a php file that display data from mysql.. i want the source code of that page displayed in a textfield box so i can use that with a copy to clipboard button..
anyone can help?
-
that worked.. thanks
-
nop... same error....
i don't know whats happening.... i'm following this video tutorial and in the video seems to work perfectly at once.... but i get this everytime
-
i'm having this on a connection to my sql db
Warning: extract() [function.extract]: First argument should be an array in /home/tontrosk/public_html/pia/display.php on line 10
here is my code
<?php include("db.php"); mysql_connect ($host, $user, $pass); mysql_select_db ($database); $result = mysql_query ("SELECT * FROM 'departamentos' ORDER BY id DESC LIMIT 2"); $row = @mysql_fetch_array($result); extract($row); echo "$nombre : $precio"; ?>
-
Does anyone knows how to place video on realtime on a webpage?
if it's a software to install or just code?
-
thanx... that solve it
-
hey everybody
little help here pliz
i have this DDBB where the table sports have seven fields, on of them is d_sports and have diferents infos:
Baseball
Basketball
Hockey
etc..
i want to select and display only the ones with Baseball info.... how can i do this??
i know is something like this:
<?php require_once('config_noticia.php'); $sql = "SELECT Baseball FROM sports ORDER BY ID DESC LIMIT 0,1"; $query = mysql_query($sql); while ($row = mysql_fetch_array($query)){ echo $row['titulo']; } ?>
thank people
-
thanks.... ill try the one from JSHINER first.... and hope that works.... if not... ill try something else.... but yeah... its hard after 20 hours
-
the image is stored in the ddbb
-
Hey people....
need this to work.... and after more than 20 hours... i can't... any help?
after the search i get results.... thats ok.... the problem comes when i try to display the image on the DDBB with that search.... just get the binary code... i also want thata image to link
this is my code
<?php if( isset ($resultmsg)){ echo $resultmsg; exit(); }else{ echo "Resultados de tu búsqueda: " . $var; } foreach($newarr as $value){ $query_value = "SELECT * FROM perfect WHERE id = '$value'"; $num_value=mysql_query ($query_value); $row_linkcat= mysql_fetch_array ($num_value); $row_num_links= mysql_num_rows ($num_value); $titlehigh = preg_replace ( "'($var)'si" , "<b>\\1</b>" , $row_linkcat[ 'nombre_evento' ] ); $linkhigh = preg_replace ( "'($var)'si" , "<b>\\1</b>" , $row_linkcat[ 'nombres' ] ); $linkimg = preg_replace ( "'($var)'si" , "<b>\\1</b>" , $row_linkcat[ 'img_portada' ] ); $contenttype = preg_replace ( "'($var)'si" , "<b>\\1</b>" , $row_linkcat[ 'FileType' ] ); foreach($trimmed_array as $trimm){ if($trimm != 'b' ){ $titlehigh = preg_replace( "'($trimm)'si" , "<b>\\1</b>" , $titlehigh); $linkhigh = preg_replace( "'($trimm)'si" , "<b>\\1</b>" , $linkhigh); $linkimg = preg_replace( "'($trimm)'si" , "<b>\\1</b>" , $linkimg); $contenttype = preg_replace( "'($trimm)'si" , "<b>\\1</b>" , $contenttype); } ?> </span> <p> <span class="styleform"> <?php header("Content-type:$contenttype"); ?> <?php echo '<img src=' . $linkimg . ' alt="" width="100" height="70" border="0"></a>'; ?> <?php echo $titlehigh; ?><br> <?php echo $linkhigh; ?><br><br> </span></p> <span class="styleform"> <?php } //end foreach $trimmed_array if($row_num_links_main > $limit){ if ($s>=1) { // do not display previous link if 's' is '0' $prevs=($s-$limit); echo "<div align='left'><a href='$PHP_SELF?s=$prevs&q=$var&catid=$catid'>Anterior " .$limit. "</a></div>"; } $slimit =$s+$limit; if (!($slimit >= $row_num_links_main) && $row_num_links_main!=1) { $n=$s+$limit; echo "<div align='right'><a href='$PHP_SELF?s=$n&q=$var&catid=$catid'>Siguiente " .$limit. "</a></div>"; } } } ?>
-
thanks for trying to help... the code from charlieholder looks cleaner... but have the same error....
Parse error: syntax error, unexpected '}' in /home/mytrende/public_html/p_search.php on line 19
if anybody knows from a good search tutorial link... so i can check what i;m doing wrong
-
this is the error i get after the search is made:
Parse error: syntax error, unexpected T_ELSE in /home/mytrende/public_html/p_search.php on line 23
and the code is like this:
<?
if (isset($keywords) && $keywords != "") {
$searchterms = $_GET["keywords"];
$query = "select * from perfect where match(nombre_evento,texto_evento) against('".mysql_real_escape_string($searchterms)."')";
$result = mysql_query($query);
if ($row = mysql_fetch_array($result)) {
print"<br /><b>Your search returned ".mysql_num_rows($result)." results.</b>";
$i = 1;
do {
print"<br /><br />This is search result number {$i}";
$i++;
{ while ($row = mysql_fetch_array($result));
} else {
print"<br />Your search returned no results."
} else {
include('picture_search.php');
}
?>
-
Help with ORDER a result
in PHP Coding Help
Posted
Thaks for the tip... but AVG won't fix the problem 'cause i need to order the RESULT of two different columns divided. That value is not in MySql.