Jump to content

Darkwoods

Members
  • Posts

    88
  • Joined

  • Last visited

Posts posted by Darkwoods

  1. 11 minutes ago, Barand said:

    explode() on the "|" to get the 3 main sections

    explode each of those on "=" to get the key and the values

    explode the values using ","

     

    Yes this is how I managed to do it but not so sure if it looks good..

    but it works

    $text = 'cat1=hello,world|cat2=one,two|cat3=value1,value2';
    $arr= explode('|', $text);
    
    foreach($arr as $value)
    {
    	$key = rtrim(stristr($value, '=', true), '=');
    	$values = ltrim(stristr($value, '='), '=');
    	$values = explode(',', $values);
    	$array[$key] = $values;
    }
    
    print_r($array);

     

     

     

  2. hey thanks I know it looks awful that because I am total noob  ::)

     

    I'm still having problem with displaying the name of the category please if anybody can help me out with it would be great I have been stuck with this for a while now..

     

    <?PHP $result = mysql_query("SELECT a.*, b.c_id, b.c_title FROM properties AS a JOIN cat AS b ON SUBSTRING_INDEX(a.pr_category, ',', 1) = b.c_id",$connect);
    	while($row = mysql_fetch_assoc($result))
    		{
    		$cat_name = $row["c_title"];
    		$cat_id = $row["c_id"];
        			$categories = explode(',', $row['pr_category']);
    /*test*/
        foreach ($categories as $category) {
            list($cat_id, $cat_name) = explode('=', $category);
            echo '' . $cat_id . ':' . $cat_name . ''; } }
    
    ?>

     

     

     

  3. Hey in my category field I got multiple values in the same mysql row

    I'm having problem with how to separate them so I can display the name of the category and make a link for each category..

     

    the multiple values are something like that 1,2

    how can I make it so it would separate after each comma?

     

     

     <?PHP $result = mysql_query("SELECT a.*, b.c_id, b.c_title FROM properties AS a JOIN cat AS b ON a.pr_category = b.c_id",$connect);
    	while($row = mysql_fetch_assoc($result))
    		{ ?>
                
                <h2><a href="blog-post.php?id="><?php echo $row['pr_title']; ?></a></h2>
                <p class="date">12 July 2011 in <a href="index.php?id<?php echo $row['c_id']; ?>"><?php echo $row['c_title']; ?></a></p>
                <img class="img-large-bg" src="../uploads/images/<?php echo $row['f_img'];  ?>" alt="" title="" />
          	<?PHP 
    		}
    			?>

  4. Try running:

    SELECT a.*, b.title FROM properties AS a JOIN categories AS b ON a.pr_category = b.id
    

     

    I would suggest running that query inside your database management software (phpMyAdmin), or the console, to make sure it returns the data you expect.  This will save you coding time.

     

    Hey your code worked but my remaining problem is how do I display the name of multi categories for example in the mysql field I got 1,2 which are cat1 and cat2

     

    so far I'm only seeing the name of one category

  5. Hey I'm trying to display the names of the categories  but the values are numbers connected to another table with the title of the category

    and the other problem is that sometimes it is multi categories selected and this will make a value like 1,2 so how can I solve this please?

     

    here is my messed up code and there seems to be something wrong with it..

     

     <?PHP $result = mysql_query("SELECT * FROM properties, categories ",$connect);
    	while($row = mysql_fetch_assoc($result))
    		{
    				$pr_category = $row["pr_category"];
    		?>
                
                <h2><a href="blog-post.html"><?php echo $row['pr_title']; ?></a></h2>
                
    <?PHP $result = mysql_query("SELECT * FROM categories WHERE id='$pr_category' ",$connect);
            while($row = mysql_fetch_assoc($result)) 
    	{
    	$cat_title = $row["title"]; ?>
    
                <p class="date">12 July 2011 in <a href="#"><?php echo $cat_title; } ?></a></p>
                <img class="img-large-bg" src="../uploads/images/<?php echo $row['f_img']; } ?>

  6. I'm guessing what you mean is, that you have something that drives how many tabs you need.  If so, you should make a function that outputs the tab code, and generates the id based on a counter in the loop.  Inside that function the div would be something like:

     

    function makeTab($id, $img, $h1, $para) {
      $out = '<div id="fragment-' . $id . '" class="ui-tabs-panel">
                  <img src="assets/img/' . $img . '" title="" // etc
       return $out;
    }
    

     

     

    Hey thanks for your reply but this wont solve the problem the jQuery tabs im using is for news posts so the fragment tabs have to be the same 1,2,3,4 it wont work with id.

     

    is there a way to tell the mysql to echo the latest  second or third or forth post?

     

    this way I can echo it in every fragment..

     

     

     

  7. Hello I got an jQuery tabs and every tab got ID "fragment-1", "fragment-2" and so on

     

    now if want to tell PHP to use fragment-2 if fragment-1 is taken how do I do that?

     

    Thanks

     

                <div id="fragment-1" class="ui-tabs-panel">

                    <img src="assets/img/image1.jpg" title="" alt="" />

                    <div class="info" >

                        <h1><?php echo $row['pr_title']; ?></h1>

                        <p>blabla..</p>

                    </div>

                </div>

  8. Hey im having troube making this code as i have no idea how to do it...

     

    basically what im trying to do is for example if the index.php?id=XXX i want to echo "this" and if it is just index.php i want to echo "that"

     

    your help would be nice thanks :)

     

    		<?php
    	$id_lang = $_GET['id'];
    	if($id_lang == $id_lang){
            $result = mysql_query("SELECT * FROM pages WHERE id='$id_lang' ",$connect);
            while($row44 = mysql_fetch_assoc($result))
    		{
    			$js_langdir = $row44['lang_dir']; }}
    
    	else{
    	$js_langdir = "LTR";
    				}
    ?>

  9. i tried addslashes() but it is still the same :(

    magic_quotes_gpc()  is on know and it didn't change anything

     

     

    yeah there is a DB connection the data is getting to the mysql but for example if i try to add text such as ( The whatever ‘Countdown’ will begin now!) the text will cut and will only get  (The whatever) to the database

     

     

    Have you made a DB connection at that point?

     

    Try this and see if it makes a difference:

    $name = mysql_real_escape_string($_POST['name'], $connect);
    

  10. i just fixed the $_SERVER['PHP_SELF'] thanks for the advice :)

     

    i added

     

    if( isset($_POST['name']) ) {
         $name = mysql_real_escape_string($_POST['name']);
    }

     

    but i'm still having problem with bypassing characters which are not supported such as ‘  it is sending the data to the mysql now unlike before but it cuts the text if there is an ‘

     

    what should i do?

     

    thanks

  11. Hey I wasn't able to add/edit some text to the mysql database because of some character

    how can i bypass them

    should i use the mysql_real_escape_string() ? if yes how do i make it work with the code i got?

     

    thaks

     

    <?php
    include "../configdb.php";
    
    $id = $_GET['id'];
    if(isset($_POST['submit']))
    {
        //global variables
    $name = $_POST['name'];
    $footer = $_POST['footer'];
    
    
    //run the query which adds the data gathered from the form into the database		   
    $result = mysql_query("UPDATE pages SET name='$name', footer='$footer' WHERE id='$id' ",$connect);
    echo "<b>Your Page have been edited successfully";
    // echo "<meta http-equiv=Refresh content=2;url=index.php>";
    }
    elseif($id)
    {
    	$result = mysql_query("SELECT * FROM pages WHERE id='$id' ",$connect);
            while($row = mysql_fetch_assoc($result))
    		{
    			 ?>
    
    <h3>::Edit Page</h3>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?php echo $row['id']?>">
    <input type="hidden" name="id" value="<?php echo $row['id']?>">
    <textarea name="name"><?php echo $row['name']?></textarea>
    <input name="footer" size="40" maxlength="255" value="<?php echo $row['footer']?>">
    <input type="submit" name="submit" value="Submit">       
    
         
          <?php
    		}
    }
    ?>

  12. Hey i keep getting undefined  index error when i submit the editing page I cant figure out what the problem is I have checked if i have miss spelled anything from the mysql table and i haven't  please help everything exist in mysql but still im getting this error and not letting me update it :(

     

     

    Notice: Undefined index: uruklink in D:\wamp\www\admin\edit.php on line 8

    Notice: Undefined index: ketabsetlink in D:\wamp\www\admin\edit.php on line 9

     

    <?php
    include "../configdb.php";
    
    $id = $_GET['id'];
    if(isset($_POST['submit']))
    {
        //global variables
    $uruklink = $_POST['uruklink'];
    $ketabsetlink = $_POST['ketabsetlink'];
    
    
    //run the query which adds the data gathered from the form into the database		   
    $result = mysql_query("UPDATE softlinks SET uruklink='$uruklink', ketabsetlink='$ketabsetlink' WHERE id='$id' ",$connect);
    echo "<b>Your Page have been edited successfully";
    // echo "<meta http-equiv=Refresh content=2;url=index.php>";
    }
    elseif($id)
    {
    	$result = mysql_query("SELECT * FROM softlinks WHERE id='$id' ",$connect);
            while($row = mysql_fetch_assoc($result))
    		{
    			$uruklink = $row['uruklink'];
    			$ketabsetlink = $row['ketabsetlink']; ?>
    
    <h3>::Edit Page</h3>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?php echo $row['id']?>">
    <input type="hidden" name="id" value="<?php echo $row['id']?>">
    <input name="name" size="40" maxlength="255" value="<?php echo $uruklink; ?>">
    <input name="footer" size="40" maxlength="255" value="<?php echo $ketabsetlink; ?>">
    <input type="submit" name="submit" value="Submit">       
    
         
          <?php
    		}
    }
    ?>

  13. Hey there is no error with this code it works just fine but I would love to know if there is unnecessary coding in it  for example do i have to do the global variables? is there a better way to do mysql editing page?

     

    thanks

     

    <?php
    include "../configdb.php";
    
    $id = $_GET['id'];
    if(isset($_POST['submit']))
    {
        //global variables
    $name = $_POST['name'];
    $footer = $_POST['footer'];
    
    
    //run the query which adds the data gathered from the form into the database		   
    $result = mysql_query("UPDATE pages SET name='$name', footer='$footer' WHERE id='$id' ",$connect);
    echo "<b>Your Page have been edited successfully";
    }
    elseif($id)
    {
    	$result = mysql_query("SELECT * FROM pages WHERE id='$id' ",$connect);
            while($row = mysql_fetch_assoc($result))
    		{
    			$name = $row['name'];
    			$footer = $row['footer']; ?>
    
    <h3>::Edit Page</h3>
    <form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?id=<?php echo $row['id']?>">
    <input type="hidden" name="id" value="<?php echo $row['id']?>">
    <input name="name" size="40" maxlength="255" value="<?php echo $name; ?>">
    <input name="footer" size="40" maxlength="255" value="<?php echo $footer; ?>">
    <input type="submit" name="submit" value="Submit">       
    
         
          <?php
    		}
    }

     

×
×
  • 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.