PHP - Moved: Need Help With Colums
This topic has been moved to Third Party PHP Scripts.
http://www.phpfreaks.com/forums/index.php?topic=313547.0 Similar TutorialsI am trying to get the output for a mysql query to be displayed in colums. I have it where it does this but it goes from left to right. I would rather it go from top to bottem, it would look better this way. I will also need it to brake into sevral pages when there are a certain amout of entrys shown. If you know of a good how to on that let me know please. The other problom that I am having is to make the output a link. I was able to do this before I attemped to devide everything but if I add in what I had before it comes back with no data. Here's what I have now that put shows the data from left to right in 2 colums. Code: [Select] <?php include"scripts/connect.php" ; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM movies WHERE type LIKE 'movie' ORDER BY title"; if(mysql_query($query)) { $result=mysql_query($query); $num=mysql_numrows($result); } for($i=0; $i<$num; $i++) { if($i%2==0){ echo "<tr><td>"; } else{ echo "<td>"; } print mysql_result($result,$i,"title"); if ($i%2==0){ echo "</td>"; } else{ echo "</td>"; } } echo "</tr>"; ?> Thanks in advance I Have a page that will display the data that was posted into a database, but it displays it like this: id logoname locationname address city state zip phone website etc... I want to display the data like this: id <--- this will repeat records 4 columns across logoname locationname etc... id <--- this will repeat records 4 columns across logoname locationname etc... and then repeat similar for the rest of the data. Sorry Im a n00b, but trying. Here is the current code: <?php include "config.php"; $con = mysql_connect("$dbhost","$dbusr","$dbpass"); if (!$con) { die('Could not connect:'. mysql_error()); } mysql_select_db("$dbname",$con); $q="select * from venues"; $result=mysql_query($q); if (!$result) { die("Query to show fields from table failed"); } $fields_num = mysql_num_fields($result); echo "<table border='0'><tr>"; for($i=0; $i<$fields_num; $i++) { $field = mysql_fetch_field($result); echo "<td></td>"; } echo "</tr>\n"; while($row = mysql_fetch_row($result)) { echo "<tr>"; foreach($row as $cell) echo "<td>$cell</td>"; echo "</tr>\n"; } mysql_free_result($result); ?> Help would be greatly appreciated and an explanation so that I don't have to keep asking hello, normally when i query mysql, it returns my results line by line. im trying to make a print view now that will put 3 results in a row before going to the next row. any help appreciated. Hello I have a custom php cart working great, with product pages and shopping cart and checkout using points rather than money. My problem is that I cannot get the actual product pages to display in colums (I want 5 items per colum and 8 rows per page). Instead the whole thing is displayed as a row. Here is the page that the products are shown on: http://www.theskinnyminnie.com/user/rent/ (I have removed the need to be signed on) Here is the code I am using: Code: [Select] <?php // Run a select query to get myproducts $dynamic List =""; $sql = mysql_query("SELECT * FROM Products ORDERY BY date_added DESC"); $productCount = mysql_num_rows($sql)){ if(productCount > 0){ while($row = mysql_fetch_array($sql)){ $id = $row["product_id"]; $product_name = $row["product_name"]; $price = $row["credits"]; $date_added = strftime("%b %d, %Y", strtotime($row["date_added"])); $dynamicList .= '<tr> <td><a href="product.php?id=' . $id . '"><img src="inventory_images/' . $id . '.jpg" alt="' . $product_name . '" width="77" height="102" border="1" /></a></td></tr> <tr> <td><a href="product.php?id=' . $id . '">' . $product_name . '</a></td> </tr> <tr> <td>' . $price . 'pts</td> </tr> <tr> <td> </td> </tr>'; } } else { $dynamicList = "We have no products listed in our store yet"; } mysql_close(); ?> and then i echo dynamicList I have been working on a way to split my data into 2 columns as a way to make the page shorter and easier to read. I have been able get it to split like this 1 2 3 4 5 6 But I would rather it go like this, because it would be easier on the eyes. 1 4 2 5 3 6 This is what I have now, I have no idea if I'm even on the right track. Code: [Select] <?php include"scripts/connect.php" ; mysql_connect('localhost',$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM movies WHERE type LIKE 'tv' ORDER BY title"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table width="70%" align="left"> <?php $i=0; while ($i < $num/2) { $title=mysql_result($result,$i,"title"); ?> <tr> <td><a class="nav" href=/show.php?title=<?php echo urlencode($title); ?>><?php echo $title; ?></td> <?php while ($i >= $num/2) { ?> <td><a class="nav" href=/show.php?title=<?php echo urlencode($title); ?>><?php echo $title; ?></td> </tr> <?php } $i++; } ?> </table> This will show only the first half of the titles. Thanks in advance. What I am trying to do is create a search box to search for a specific piece of information in my client database, say last name, or account number, invoice number, etc. is there a way i can use the keyword to match the query to multiple columns? here is my code, the script works if i use the $query to select just 1 column. but how do i add other columns to match it to? I know its where "different columns" LIKE search my problem is this line basically. Code: [Select] mysql_select_db("terra_elegante_operations", $con); $searchfor = $_GET['search_term']; $query = "select * from client_information where name_last like \"%$searchfor%\""; $result = mysql_query($query) or die("Couldn't execute query"); $row = mysql_fetch_array($result); echo $row['0']; I hope this entry finds everyone safe and healthy. I am trying to extract table data and schema info from a database WITHOUT knowing the field names. Essentially, I want to connect to the database and have the information for each table deposited into an HTML format (just like I'd see if I accessed the db directly). I've found several methods online, but all use DEPRICATED coding that will no longer function. Any code or links to assist in resolution would be appreciated. Stay safe, and thank you. I am pulling some info from a mysql table, checking some logic, and displaying in on a page. The way this is written now it shows all of the items in a one column table, I simply want to break it up into multiple columns (ideally by specifying say 20 items per column). I know I need a counter and a loop but I'm just not sure how it all fits in with my existing program. Any help would be greatly appreciated. Here is my code Code: [Select] $result2 = mysql_query("SELECT * FROM propertyids ORDER BY propertyname ASC"); while($row2 = mysql_fetch_array($result2)){ ${'resp'.$row2['id']} = curl_multi_getcontent(${'ch'.$row2['id']}); ${'status'.$row2['id']} = strpos(${'resp'.$row2['id']},$httpvar); if(${'status'.$row2['id']} === false) { echo "<tr><td>"; echo "<img src='images/down.png'> <a href='" . $row2['primaryurl'] . "' target='_blank'>" . $row2['propertyname'] . "</a>"; echo "</td></tr>"; } else { echo "<tr><td>"; echo "<img src='images/up.png'> <a href='" . $row2['primaryurl'] . "' target='_blank'>" . $row2['propertyname'] . "</a>"; echo "</td></tr>"; } } echo "</td></table>"; I am using the following code to generate a dynamic drop down menu from a column in table1(name) - and then inserting the selected option into table2. What I am trying to do is, select data from 2 columns from table1(name,age) and then store and insert both of those values into table2 I am hoping someone can help me out or at least point me in the rigth direction. ..I would like to insert into table 2 the age that matches the person selected by the drop down menu from table1. For example - if from the drop down menu I choose John - when the form is sumbitted i want to insert into table2 John's name and age (based on what is stored in table1, in this case John,22) ...Any ideas??? table1 id|name|age|score 01-john-22-1547 02-jane-22-1245 table2 id|county|name|age the dynamic drop down is generated from table1 (name) with following code Code: [Select] <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>"> <table width="100%" border="0" cellpadding="5" cellspacing="0"> <?php require_once('sql.php'); $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); $query="SELECT name FROM table1 ORDER BY name ASC"; $result = mysqli_query ($dbc,$query) or die(mysqli_error()); $dropdown = "<select name='name'>"; while($row = mysqli_fetch_array($result)) { $dropdown .= "\r\n<option value='{$row['name']}'>{$row['name']}</option>"; } $dropdown .= "\r\n</select>"; echo $dropdown; ?> <tr> <td height="50" align="right"> <label for="scheduled_time">Country</label><br/> </td> <td align="left"> <input type="text" id="country" name="country" class="input" maxlength="30"" /> </td> </table> <p></p> <input type="submit" value="Add Info" name="submit" /> </form> I am inserting into table2 with the following code Code: [Select] <?php $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); if (isset($_POST['submit'])) { $county = mysqli_real_escape_string($dbc, trim($_POST['country'])); $name = mysqli_real_escape_string($dbc, trim($_POST['name'])); $query = "INSERT INTO table2 (country, name) VALUES ('$country', '$name'')"; $result = mysqli_query($dbc, $query); if (!$result) { printf("query error : <br/> %s\n", mysqli_error($dbc)); } if ($result) { echo 'Success'; } // close dbc mysqli_close($dbc); exit(); } ?> hirealimo.com.au/code1.php this works as i want it: Quote SELECT * FROM price INNER JOIN vehicle USING (vehicleID) WHERE vehicle.passengers >= 1 AND price.townID = 1 AND price.eventID = 1 but apparelty selecting * is not a good thing???? but if I do this: Quote SELECT priceID, price FROM price INNER JOIN vehicle....etc it works but i lose the info from the vehicle table. but how do i make this work: Quote SELECT priceID, price, type, description, passengers FROM price INNER JOIN vehicle....etc so that i am specifiying which colums from which tables to query?? thanks This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=315910.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=356314.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=314397.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=346829.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=328753.0 This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=356760.0 This topic has been moved to PHP Installation & Configuration. http://www.phpfreaks.com/forums/index.php?topic=319595.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=318465.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=313579.0 The PHP Coding Help section is not the place to recruit someone to work on your project. It's for answering specific questions about specific code. This topic has been moved to PHP Freelancing. http://www.phpfreaks.com/forums/index.php?topic=347446.0 |