Jump to content

Help (PHP)


Monk3h

Recommended Posts

How would i get something in my database to be listed on a page?

 

For example, i want every development name in the development table with an ID Less than the current development ID to be listed, seperated by a ,.

 

So if the current development being developed was number 5 i woulod want this to be listed.

 

 

DEV 1 Name, DEV 2 Name, DEV 3 Name, DEV 4 Name.

 

 

How would i do this? :/

Link to comment
https://forums.phpfreaks.com/topic/100189-help-php/
Share on other sites

Something like this:

 

<?php
// assuming there's a variable called $id that has the current id assigned to it
$query = "SELECT `id` FROM `table` WHERE `id` < '$id'";
$run = mysql_query($query);
if($run){
  while($arr = mysql_fetch_assoc($run)){
     extract($arr);
     echo "id = $id<br />";
  }
}else{
  die("Unable to connect to database.");
}
?>

 

You should just be able to manipulate the code to your scenario.  Is this what you are attempting to do?

Link to comment
https://forums.phpfreaks.com/topic/100189-help-php/#findComment-512299
Share on other sites

write a simple script like this:

<?php
include("YOUR CONFIG FILE HERE");
$d_id = $_GET['d_id'];
$sql = mysql_query("SELECT * FROM `INSERT YOUR TABLE NAME HERE` WHERE `did` = '. $d_id .'") or die(mysql_error());
$product = mysql_fetch_array($sql);
echo $product['name'];
?>

please put your own information in in, and also to write any detail from the row, you can use

echo $product[' and then any field from that section, then close it off with'];

 

Your Welcome!

-Zack

PS: I was once like you so don't worry about it.

PSS: The guy above me beat me to it =/

Link to comment
https://forums.phpfreaks.com/topic/100189-help-php/#findComment-512301
Share on other sites

Thank you both VERY much but i cant seem to get it to work..

 

<?php $title = "Developments"; include("header.php"); ?>	

<?php
$mytribe = mysql_fetch_array(mysql_query("select * from tribes where id=$stat[tribe]"));
$devcount = mysql_fetch_array(mysql_query("select * from dev where id=$mytribe[devcount]+1"));

	Print "Here is where you keep your Tribe up to date with the latest Defensive and Offensive Technologies! Remember.. Nothing is Impossible when you have a Tank!<br><Br><br><br>";

	Print "Your Tribe Currently have <b>$mytribe[devcount]</b> Developments Completed.<br><br>";

if ($mytribe[devtime] > 0){
	Print "Your Tribe is currently Developing <b>$devcount[name],</b> this development will be completed in Approximately <b>$mytribe[devtime]</b> Hours.<br><br>";
}

	Print "<b><u>Avalible Developments</u></b><br><br>";
	Print"
<table border='0' bordercolor='' width='95%' bgcolor=''>
    <tr>
      <td><b>Development Name</b></td>
      <td><b>Time Required</b></td>
      <td><b>Cost</b></td>
      <td><b>Action</b></td>
    </tr>
      <tr>
      <td>$devcount[name]</td>
      <td>$devcount[time]</td>
      <td>$devcount[cost]</td>
      <td><a href=development.php?action=start>Start</a>
    </tr>
</table>";

if ($action == start) {

if ($stat[id] == !$mytribe[owner]) {

Print "You are not the Tribe Owner, you dont have the authority to start a Development";
}

elseif ($mytribe[devtime] > 0){

Print "<br><br><br>You are Currently Developing <b>$devcount[name]</b>, you cannot do 2 Developments at once!";

}else{

if ($mytribe[credits] < $devcount[cost]){

Print "<br><br><br>Your Tribe does not have enough Credits for that Development!";

}else{

mysql_query("update tribes set credits=credits-$devcount[cost] where id=$mytribe[id]");
mysql_query("update tribes set devtime=devtime+$devcount[time] where id=$mytribe[id]");

Print "<br><br><br> Your Tribe has started <b>$devcount[name]</b><br>This Development will take Approximately <b>$devcount[time]</b> Hours<br>This development cost your Tribe <b>$devcount[cost]</b> Credits";

}}}

?>

<?php include("footer.php"); ?>

 

 

Thats my Script.. How would i put that code into this Script? one Give me the uneeded $end error the other Says Wrong Syntax. :/

Link to comment
https://forums.phpfreaks.com/topic/100189-help-php/#findComment-512331
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.