Jump to content

deansatch

Members
  • Posts

    300
  • Joined

  • Last visited

Everything posted by deansatch

  1. you shouldn't post your database login details.
  2. It's exactly the same in your php as a text input field. You are getting the $_POST['fieldname'] and inserting into your database. If it is a select field, i.e. your gender one is named "element_2", you simply get that value e.g. $_POST[element_2'] e.g. <select class="element select medium" id="element_2" name="gender"> <option value="" selected="selected"></option> <option value="1" >Male</option> <option value="2" >Female</option> </select> and your php to get this and insert in to db would be something like $gender= $_POST['gender']; $query = "INSERT INTO users (gender) VALUES ('$gender')"; [/code
  3. If I understand you correctly: save your two menus as smallmenu.php and extramenu.php then on your index page: include('smallmenu.php'); on us.php: include('extramenu.php'); include('smallmenu.php');
  4. Your form needs to submit to your php file <form id="form_29490" class="appnitro" method="post" action="yourphpfile.php"> then you need to get your form field results in your php file. I don't know where the date of birth one is on your form. Make sure your calendar picker actually sends a result to a form field. $gender = $_POST['element_2']; $dob=$_POST['whateveryourfieldnameis']; //connect to db $query = "INSERT INTO users (idob, gender) VALUES ('$dob', '$gender')";
  5. for future posts.It is probably best not to post your database username and password etc...
  6. Here is the finished code $ct = 0; $store = Array(); mysql_connect($server1, $username, $pwd); mysql_select_db($db1); $result = mysql_query("SELECT * FROM table_3 WHERE id > 0 "); while($row=mysql_fetch_array($result)) { $date[6][$ct] = $row["date"]; $store[0][$ct] = date("l jS F Y", strtotime($date[6][$ct]) ); $store[1][$ct] = $row["venue"]; $store[2][$ct] = $row["tickets"]; $store[3][$ct] = $row["time"]; $store[4][$ct] = $row["address"]; $store[5][$ct] = "#0000ff"; ++$ct; } mysql_connect($server2, $username2, $pwd); mysql_select_db($db2); $result = mysql_query("SELECT * FROM table_1 WHERE id > 0 "); while($row=mysql_fetch_array($result)) { $date[6][$ct] = $row["date"]; $store[0][$ct] = date("l jS F Y", strtotime($date[6][$ct]) ); $store[1][$ct] = $row["venue"]; $store[2][$ct] = $row["tickets"]; $store[3][$ct] = $row["time"]; $store[4][$ct] = $row["address"]; $store[5][$ct] = "#ff0000"; ++$ct; } $st = array_multisort($date[6],SORT_DESC,$store[0], $store[1], $store[2], $store[3], $store[4], $store[5]); $ct_end = $ct - 1; echo '<table border="1">'; echo '<tr>'; echo '<th align="center">Date</th>'; echo '<th align="center">Venue</th>'; echo '<th align="center">Tickets</th>'; echo '<th align="center">Time</th>'; echo '<th align="center">Address</th>'; echo '</tr>'; for ($i = 0; $i <= $ct_end; ++$i) { echo <<<EOT <tr> <td style="align:center;color:{$store[5][$i]};">{$store[0][$i]}</td> <td style="align:center;color:{$store[5][$i]};">{$store[1][$i]}</td> <td style="align:center;color:{$store[5][$i]};">{$store[2][$i]}</td> <td style="align:center;color:{$store[5][$i]};">{$store[3][$i]}</td> <td style="align:center;color:{$store[5][$i]};">{$store[4][$i]}</td> </tr> EOT; } echo '</table>';
  7. problem solved using array_multisort See the result here http://www.pennysbackinblack.co.uk/gigscomb.php
  8. Using date = $date1 makes the db2 results disappear. I assume this is because it is trying to display results from database 2 which are on the same dates as database 1 results. However, there should be no 2 gigs on the same date anyway. The record_id works for displaying them all, it just seems impossible to get them sorted.
  9. Thanks Something I don't understand is why on the second mysql query do I have to use id = $record_id. Why can't it be the same query as the first "WHERE id > 0 ORDER BY date desc"? And why is it not ordering my second database results?
  10. Here is the page in question http://www.pennysbackinblack.co.uk/pages.php?id=3&c=giglistcomb The white text is $db The Blue text is $db2 I want them all in date order Hope that makes more sense
  11. Thanks That just seems to eliminate the $db2 results completely. Still not sure why I have the record_id bit aswell
  12. $connection = mysql_connect($host,$usr,$pwd); mysql_select_db($db,$connection); $q1 = mysql_query("SELECT * FROM table_$id WHERE id > 0 ORDER BY date desc") ; while($row = mysql_fetch_array($q1)) { $record_id = $row[0]; $date1 = $row[1]; $date = date("l jS F Y", strtotime($date1) ); $venue = $row[2]; $tickets = $row[3]; $time = $row[5]; $address = $row[4]; echo "<div>"; echo "$date"; echo "---"; echo "$venue"; echo "</div>"; $connection2 = mysql_connect($host2,$usr2,$pwd2); mysql_select_db($db2,$connection2); $q2 = mysql_query("SELECT * FROM table_1 WHERE (id = $record_id)") ; while($row2 = mysql_fetch_array($q2)) { $date2 = $row2[1]; $date3 = date("l jS F Y", strtotime($date2) ); $venue2 = $row2[2]; $tickets2 = $row2[3]; $time2 = $row2[5]; $address2 = $row2[4]; echo "<div><font style='color:#ccf'>"; echo "$date3"; echo "---"; echo "$venue2"; echo "</font></div>"; } } This is the closest I have gotten. This shows $db results in date desc order and merged in to them results it shows $db2 in date random order. All the dates are there they just aren't sorted right. What is it I am doing wrong?
  13. Why (id = '$record_id') ? I am getting closer to a result with this method. No errors but it isn't putting them in any specific order. I have the merged results though. $connection = mysql_connect($host,$usr,$pwd); mysql_select_db($db,$connection); $q1 = mysql_query("SELECT * FROM table_$id WHERE id > 0 ORDER BY date desc") ; while($row = mysql_fetch_array($q1)) { $record_id = $row[0]; $date1 = $row[1]; $date = date("l jS F Y", strtotime($date1) ); $venue = $row[2]; $tickets = $row[3]; $time = $row[5]; $address = $row[4]; $connection2 = mysql_connect($host2,$usr2,$pwd2); mysql_select_db($db2,$connection2); $q2 = mysql_query("SELECT * FROM table_1 WHERE (id = '$record_id')") ; while($row2 = mysql_fetch_array($q2)) { $date2 = $row2[1]; $date3 = date("l jS F Y", strtotime($date2) ); $venue2 = $row2[2]; $tickets2 = $row2[3]; $time2 = $row2[5]; $address2 = $row2[4]; if ($date1 < $todaysdate){ echo '<div class="container"> <div class="thegig"> <table> <tr> <td class="info"></td> <td class="dategiggrey">'. $date .'</td> <td class="venuegrey">'. $venue .'</td> </tr> </table> </div > <div class="information"> <table class="gigaddressgrey"> <tr> <td>'. $address .'</td> </tr><tr> <td> '. $time .'</td> </tr><tr> <td>'. $tickets .'</td> </tr> </table> </div > </div >'. "\n"; $rgb -= $speed; } if ($date2 < $todaysdate){ echo '<div class="container"> <div class="thegig"> <table> <tr> <td class="info"></td> <td class="dategiggrey">'. $date3 .'</td> <td class="venuegrey">'. $venue2 .'</td> </tr> </table> </div > <div class="information"> <table class="gigaddressgrey"> <tr> <td>'. $address2 .'</td> </tr><tr> <td> '. $time2 .'</td> </tr><tr> <td>'. $tickets2 .'</td> </tr> </table> </div > </div >'. "\n"; $rgb -= $speed; } if ($date1 >= $todaysdate){ echo '<div class="container"> <div class="thegig"> <table> <tr> <td class="info"></td> <td class="dategigblack">'. $date .'</td> <td class="venueblack">'. $venue .'</td> </tr> </table> </div > <div class="information"> <table class="gigaddressblack"> <tr> <td>'. $address .'</td> </tr><tr> <td> '. $time .'</td> </tr><tr> <td>'. $tickets .'</td> </tr> </table> </div > </div >'. "\n"; $rgb -= $speed; } if ($date2 >= $todaysdate){ echo '<div class="container"> <div class="thegig"> <table> <tr> <td class="info"></td> <td class="dategigblack">'. $date3 .'</td> <td class="venueblack">'. $venue2 .'</td> </tr> </table> </div > <div class="information"> <table class="gigaddressblack"> <tr> <td>'. $address2 .'</td> </tr><tr> <td> '. $time2 .'</td> </tr><tr> <td>'. $tickets2 .'</td> </tr> </table> </div > </div >'. "\n"; $rgb -= $speed; } } }
  14. I have half got it. This is what I have so far but it only outputs the results of $db2. Somehow I need to merge the results of each array before sorting them out.$example2 is overriding $example1 in my variable assignments i.e. $date, $venue etc... How can I make for example, $date1 = $example1 results together with $example2 results? $connection = mysql_connect($host,$usr,$pwd); mysql_select_db($db,$connection); $q1 = mysql_query("SELECT * FROM table_$id WHERE id > 0 ORDER BY date desc") ; while($row1 = mysql_fetch_array($q1)) { $example1 = $row1; $connection = mysql_connect($host2,$usr2,$pwd2); mysql_select_db($db2,$connection); $q2 = mysql_query("SELECT * FROM table_1 WHERE id > 0 ORDER BY date desc") ; while($row2 = mysql_fetch_array($q2)) { $example2 = $row2; $date1 = $example1["date"]; $date1 = $example2["date"]; $date = date("l jS F Y", strtotime($date1) ); $venue = $example1["venue"]; $tickets = $example1["tickets"]; $time = $example1["time"]; $address = $example1["address"]; $venue = $example2["venue"]; $tickets = $example2["tickets"]; $time = $example2["time"]; $address = $example2["address"];
  15. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '-content.table_3)' at line 1 This is the error I get. I am not really sure how to connect to the 2 databases before running the query.
  16. This is what I have so far $q = mysql_query("(SELECT * FROM table_3)UNION (SELECT * FROM table_3)"); If I do this: $q = mysql_query("(SELECT * FROM $db1.table_3)UNION (SELECT * FROM $db2.table_3)"); I get an error. How can I make it so that it takes the details from the right databases and uses the correct login for each database? Also db1 has different username to db2
  17. I did try union at first but I couldn't get it to work from the separate databases. Is it possible this way or does union only work from separate tables in the same database? I did a sort of select * from db1 union select db2 select * from db2 kind of thing but it didn't work. First time using union so I don't really know if I did it right. I just scrapped the whole thing and decided to start again. Also, once it is merged in my output, will I be able to output it as shown in original post with separate font colours so that each set of results can be distinguished? i.e. Site 1 results 10th jan - something 15th jan - something else 19th jan - more Site 2 results 11th jan - even more 13th jan - some more 16th jan - more stuff Merged page 10th jan - something 11th jan - even more 13th jan - some more 15th jan - something else 16th jan - more stuff 19th jan - more
  18. I'm confused. Basically, these are two sites, one for a band and one for a duo. I want to be able to merge their two gig lists and highlight the difference between band and duo gigs but only on one site each site is hosted on completely different servers.
  19. I have made two websites on seperate servers both with a database of their own. They are identical but with different results in the databases. I want to make a page on one of the sites that will merge the information from both databases. e.g. site 1 has a list in date order site 2 has a list in date order I want site 1 to have the list merged together to form one big list but still be in date order. Also I want to be able to have the results of site 2 in a different font colour to site 1. i.e. Site 1 results 10th jan - something 15th jan - something else 19th jan - more Site 2 results 11th jan - even more 13th jan - some more 16th jan - more stuff Merged page 10th jan - something 11th jan - even more 13th jan - some more 15th jan - something else 16th jan - more stuff 19th jan - more can anyone help with this?
  20. I have to have one table per user as it is for a guestbook per user. I'd rather keep these tables in a seperate database to the customer database. the code still doesn't work. Still getting the same messages. I thought I would have to select databases twice since I am selecting information from two different databases. Still confused.
  21. I want to write this and have $username replaced with the contents of the username field from database1 and "table1_$username" is a table in database2 [color=red]$query = mysql_query("SELECT * FROM table1_$username ORDER BY id DESC") or die(mysql_error()); [/color] I tried this during pulling my hair out and I think I am on the right track but can't get it to work. Where am I going wrong? [color=red]require("config.php"); require("functions.php"); $connection = mysql_connect($host,$usr,$pwd); mysql_select_db('database1') or die('Cannot select database'); $username = mysql_db_query($db, "SELECT username FROM table_customers where id='$id'", $connection); $connection = mysql_connect($host,$usr,$pwd); mysql_select_db('database2') or die('Cannot select database'); $query = mysql_query("SELECT * FROM table1_$username ORDER BY id DESC") or die(mysql_error()); [/color] but it just doesn't work. I can either get "Table 'databse2.table1_' doesn't exist " or "Table 'databse2.table1_Resource' doesn't exist "
×
×
  • 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.