Jump to content

pocobueno1388

Members
  • Posts

    3,369
  • Joined

  • Last visited

    Never

Everything posted by pocobueno1388

  1. They would be in a string. Although you can easily change it back to an array if you wanted like this: <?php //we will say this is the variable from the database $friends = $row['friends']; //put them back into an array $friends = explode(" ", $friends); ?>
  2. Yes, you would just do another query. You MAY be able to combine everything you want into one query and get the same results. How are the tables in your database setup? So give a detailed description of your tables, then tell us exactly what your wanting to select.
  3. Yes it is, but this has nothing to do with PHP, you would use CSS. <style type="text/css"> .bg { background-image: url(background.jpg); background-repeat: repeat-x; ## Or you could set it to repeat "y" to go the other direction } </style>
  4. Yes, you will still be able to call which name you want from the array by using the key like you did. But Bob would be $friend[2] because the counter starts at 0...here is an example. <?php $names = array("Brian","Billy","Bob","Joe"); 0 1 2 3 Does that make sense?
  5. So you want it to appear in the database in a text field as one line like so? Brian Billy Bob Joe If thats how you want it, then you would do this: <?php $names = array("Brian","Billy","Bob","Joe"); $query = "UPDATE site_table SET friends = '" . implode($names, " ") . "' WHERE user_id = 2" $result = mysql_query($query)or die(mysql_error()); ?>
  6. Here is how you would add a name later on in the script <?php $names = array("Brian","Billy","Bob","Joe"); //Add a name $names[] = "Cindy"; ?> As for your query question, I would need to see how you had your database table setup to know how to insert the information.
  7. Try this <?php include("dbinfo.inc.php"); mysql_connect(mysql,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $default_event= array('event1', 'event2'); if(isset($_REQUEST['changed']) && count($_REQUEST['changed']) > 0 && !empty($_REQUEST['command'])) { $sql = ""; $insql = "IN('" . join("','",array_keys($_REQUEST['changed'])) . "')"; switch($_REQUEST['command']) { case "Deactivate": $sql = "UPDATE birthdays SET ACTIVE='0' WHERE id " . $insql; break; case "Activate": $sql = "UPDATE birthdays SET ACTIVE='1' WHERE id " . $insql; break; case "Delete": $sql = "DELETE FROM birthdays WHERE id " . $insql; break; } if(!empty($sql)) { mysql_query($sql); } } $where = $url = array(); if(!empty($_REQUEST['event'])) { $where[] = "Event='" . addslashes($_REQUEST['event']) . "'"; $url[] = "event=" . $_REQUEST['event']; } else { $num_of_events = count($default_event); for($i=0; $i<$num_of_events;$i++){ if ($i == 0) $where[] = "Event='$default_event[$i]'"; else $where[] = " OR Event='$default_event[$i]'"; } $_REQUEST['event'] = $default_event; } if(strlen($active) > 0) { $where[] = "Active='" . addslashes($_REQUEST['active']) . "'"; $url[] = "active=" . $_REQUEST['active']; switch($active) { case 1: $page_type = "ACTIVE"; break; case 0: $page_type = "INACTIVE"; break; } } else { $page_type = "ALL"; } $query="SELECT * FROM birthdays"; if(count($where) > 0) { $query .= " WHERE " . join(" AND ",$where); } $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); echo "<A name=\"top\"></A><b><center><H1>Display Records \"<I>$page_type $default_event records</I>\":</H1>"; ?> On this line $default_event= array('event1', 'event2'); You can add as many events as you would like to the array. The code is untested, so hopefully it will work.
  8. Well, if it works then thats fine. Or you could do it this way <?php $ut= strtotime("+1 week"); echo date("Y-m-d", $ut); ?>
  9. For your first question <?php //Unix Timestamp $time = time(); //Convert $date = date("Y-m-d g:i", $time); echo $date; ?> And for your second: <?php //Unix Timestamp $time = time(); //Convert and add 7 days $date = date("Y-m-d g:i", strtotime("$date + 7 DAY")); echo $date; ?>
  10. No, I completely agree with you. The method you suggested would probably be better. That way you get the third row whether the data is corrupted or not in the DB. So that was a great thought
  11. We can't tell you whats wrong if you don't tell us the exact problem.
  12. Well, I was logically thinking that the row with an ID number of 3 WOULD be the third row. I suppose it could be different.
  13. If all you want is the third row, why not just adjust your query? I'm assuming you have some sort of auto-incremented row, we will call that "id". SELECT * FROM table_name WHERE id=3
  14. You needed to wrap the "explor.php" in quotes.
  15. Without a while loop it is only going to show the first result. Is the "GeoLoc" field in your DB empty for the first result? You might want to check that out.
  16. Okay, try this and make sure the variables are coming out right. <?php $query = "UPDATE event SET eventName = '{$eventn}', TicketsOnSale = '{$ticknum}', TicketPrice = '{$tickp}' WHERE eventid = '{$menu}'"; $result = mysql_query($query)or die(mysql_error() . "<p>With Query:<br>$query"); echo "<p>$query"; ?>
  17. Put a die statement on the query. $result = mysql_query("UPDATE event SET eventName = '{$eventn}', TicketsOnSale = '{$ticknum}', TicketPrice = '{$tickp}' WHERE eventid = '{$menu}'")or die(mysql_error());
  18. You didn't close the parenthesis. $email = mysql_real_escape_string($_POST['email']);
  19. Only put the code to create the file between the else statement brackets. <?php if (file_exists($dir)) { echo "The hub $dir exists already"; } else { //Put code to create file here echo "Hubs Sucessfully Added, Your Hub ID is "; echo "$dir"; }
  20. Thats exactly what it does...did you change the code I gave you?
  21. First try this: <?php function NextOrder($OrderID) { ConnectDatabase(); $MyQuery = "SELECT OrderID FROM `Orders` WHERE (OrderID > $OrderID)"; $request = mysql_query($MyQuery); list($Answer) = mysql_fetch_row($request); echo "DEBUG: Query is '$MyQuery', next is '$Answer'"; return $Answer; } ?> If that doesn't work, try this: <?php function NextOrder($OrderID) { ConnectDatabase(); $MyQuery = "SELECT OrderID FROM `Orders` WHERE (OrderID > $OrderID)"; $request = mysql_query($MyQuery); $row = mysql_fetch_assoc($request); $Answer = $row['OrderID']; echo "DEBUG: Query is '$MyQuery', next is '$Answer'"; return $Answer; } ?>
×
×
  • 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.