
Mutley
Members-
Posts
765 -
Joined
-
Last visited
Everything posted by Mutley
-
I set my field to the wrong type so entered loads of data like this: 0.1 0.2 0.3 etc It changed it to .1 .2 .3 How do I mass change my fields, so I don't have to re-enter it all? What field type do I need? INT?
-
I get a message on a script (The email dispatch program is currently busy. It should be free again in a few moments.), I don't know why, I narrowed it down to this part of code: <?php $ml_body = "ml_body"; $ml_head = "ml_head"; $ml_list = "ml_list"; if (file_exists("./$ml_head")){ echo "<p>"; echo ema_tag("em", "The email dispatch program is currently busy. It should be free again in a few moments."); echo "</p>"; return; } ?> Inside "ml_head" is this: Yes, the e-mails are setup correctly. Any ideas? Or ways to bypass it?
-
Thanks Frost it works, come in to take MadTechies glory, lol. Thanks alot MadTechie.
-
Not yet! It says the person is last in the que everytime, so if I have 9 users, it always says "you are position 9", regardless of where they actually are, tried different IDs too. Thanks alot so far!
-
Hehe, I get this error now, my query is definatly right as I use it earlier to select information.
-
Same error.
-
I tried that but the error repeats it's self infinity amount of times.
-
I get: I'm guessing because I need to declare it as an array()? This is what I've done: $result = "SELECT user_id, que FROM users ORDER BY que DESC"; $cont = true; $UID = 1; //users ID $counter = 0; while($row = mysql_query($result) && $cont) { $counter++; $cont = !($row['user_id'] = $UID); $cont = array(); } echo "you are position $counter";
-
Hey... don't go offtopic.
-
Could you do an example of the COUNT method please?
-
That seems more complicated than what I thought but thanks.
-
If I list all the rows in a database and "LIMIT 20", how do I make it so I can go to, the next 20 rows? Say if I have 50 rows, and only want to show 20 per a page?
-
Nope it's not necessary anymore. How would I use that, what does the "IN" statement do?
-
I have repetitive code, that selects data from an SQL table, then gives it a variable however it takes about 40 lines to do 5 different fields, here is my code: $result = mysql_query("SELECT `damage` FROM `own` WHERE user_id = '$player1' AND slot = 'car' AND loadout = '1' LIMIT 1"); while($row = mysql_fetch_array( $result )) { $damage1_car = $row['damage']; } $result = mysql_query("SELECT `damage` FROM `own` WHERE user_id = '$player1' AND slot = '1' AND loadout = '1' LIMIT 1"); while($row = mysql_fetch_array( $result )) { $damage1_1 = $row['damage']; } $result = mysql_query("SELECT `damage` FROM `own` WHERE user_id = '$player1' AND slot = '2' AND loadout = '1' LIMIT 1"); while($row = mysql_fetch_array( $result )) { $damage1_2 = $row['damage']; } $result = mysql_query("SELECT `damage` FROM `own` WHERE user_id = '$player1' AND slot = '3' AND loadout = '1' LIMIT 1"); while($row = mysql_fetch_array( $result )) { $damage1_3 = $row['damage']; } $result = mysql_query("SELECT `damage` FROM `own` WHERE user_id = '$player1' AND slot = '4' AND loadout = '1' LIMIT 1"); while($row = mysql_fetch_array( $result )) { $damage1_4 = $row['damage']; } $result = mysql_query("SELECT `damage` FROM `own` WHERE user_id = '$player1' AND slot = '5' AND loadout = '1' LIMIT 1"); while($row = mysql_fetch_array( $result )) { $damage1_5 = $row['damage']; } I'm not sure what to do, I was thinking a function but not sure how to do this, as you can see only the variable and the "slot" changes, so not much. Any help would be appreciated.
-
I have a SQL database that stores wins and losses, what I wish to do is order it in a table, so the people with the BEST ratio are at the top. I don't know how to do this, at the moment it's just ordered by the most wins, then the ratio on the end of the table worked out using some basic PHP. Here is my code: <table width="40%"> <tr> <td class="th">#</td> <td class="th">Name:</td> <td class="th">Wins:</td> <td class="th">Losses:</td> <td class="th">W/L Ratio:</td> </tr> <?php $count = 1; $sql = "SELECT user_id, 2_wins, 2_losses FROM stats ORDER BY 2_wins DESC, 2_losses LIMIT 10"; $result = mysql_query($sql); if(mysql_num_rows($result)!=0) { // (1) while(list($user_id, $wins, $losses) = mysql_fetch_row($result)) { // (2) ?> <tr> <td><?=$count++?></td> <td> <?php $result1 = mysql_query("SELECT username FROM users WHERE user_id = '$user_id'"); while($row1 = mysql_fetch_array( $result1 )) { echo $row1['username']; } ?> </td> <td><?=$wins?></td> <td><?=$losses?></td> <td> <?php if($losses == '0' && $wins == '0') { echo "0%"; } elseif($losses == '0' && $wins > '0') { echo "100%"; } else { $ratio = ($wins / ($wins + $losses)) * 100; echo round($ratio) . '%'; } ?> </td> </tr> <?php } } echo "</table>"; ?> Greatly appreciated if anyone could help.
-
Nope. It updates the first record it finds only. Probably because it's only selecting one user_id?
-
It only does 1 still. Hmm.
-
In your database make a new field called "id" set it as a MEDIUMINT (type) and auto_increment (other), as a Primary Key. Then when you click an image, you can do an 'id' (I'm guessing it lists all the images, so add the 'id' to the query) and display it in the URL of the link that will goto the new page with all the picture information on, like: <a href="info.php?id=<?=$id?> image here </a> On the info.php, you get the 'id' by doing: $id = $_GET['id']; Then make a new query to SELECT all the info WHERE id = '$id' I hope that helps!
-
Since I defined the varialbes I didn't know I had to end the bracket at the bottom? How do I make it so it loops the results then, instead of selecting the one user_id? Thanks guys.
-
Changed it to $sql1 on the second query, still does it (1 row).
-
Hmm, maybe because I'm using SELECTs then, here's my code: $result = mysql_query("SELECT user_id, job_id FROM jobs WHERE done = '0'"); while($row = mysql_fetch_array( $result )) { $user_id = $row['user_id']; $job = $row['job_id']; } if($job == '1') { $wages = '5'; } else { $wages = '0'; } $result = mysql_query("SELECT money FROM users WHERE user_id = '$user_id'"); while($row = mysql_fetch_array( $result )) { $money = $row['money']; } $earnings = $money + $wages; $sql = "UPDATE users SET money = '$earnings' WHERE user_id = '$user_id'"; mysql_query($sql); $sql = "UPDATE jobs SET done = '1' WHERE job_id = '1' AND user_id = '$user_id'"; mysql_query($sql);
-
Do I need to do a FOREACH or WHILE thing to achieve this?
-
No, you misunderstanding. That only updates ONE row, I need it to update everyone where validate='1'.
-
At the moment it only runs the query once, so only updates one row, not all of them according to the WHERE statement.